[Fortran] syntaxhighlighter_viewsource syntaxhighlighter_copycode
call assignk(props, nprops, Dim_x, Dim_y, Unit1, Unit2,
+ Wx1, Wh1, b1, bih1, Wx2, Wh2, bih2, b2, Wd, bd)
call NN_prediction(Seq_length, Dim_x, Dim_y, Unit1, Unit2, ntens,
+ input_seq_scaled, Wx1, Wh1, b1, Wx2, Wh2, b2, Wd, bd,
+ matrix_for_backprop_1, matrix_for_backprop_2,
+ matrix_for_backprop_3, stress_3d_scaled)
subroutine NN_prediction(seq_length, dim_x, dim_y, unit1, unit2,
+ ntens, input_seq_scaled, Wx1, Wh1, b1, Wx2, Wh2, b2, Wd, bd,
+ matrix_for_backprop_1, matrix_for_backprop_2,
+ matrix_for_backprop_3, stress_3d_scaled)
implicit none
! input
integer, intent(in) :: seq_length, dim_x, dim_y,
+ unit1, unit2, ntens
real*8, intent(in) :: input_seq_scaled(dim_x, seq_length)
real*8, intent(in) :: Wx1(dim_x, unit1*4), Wh1(unit1, unit1*4),
+ b1(unit1*4, 1),
+ Wx2(unit1, unit2*4), Wh2(unit2, unit2*4), b2(unit2*4, 1),
+ Wd(unit2, dim_y), bd(dim_y, 1)
! output
real*8, intent(out) :: stress_3d_scaled(dim_y)
real*8, intent(out) :: matrix_for_backprop_1(unit1,10),
+ matrix_for_backprop_2(unit2,10), matrix_for_backprop_3(dim_y,1)
! local variables
real*8 h1(unit1, 1), c1(unit1, 1), h2(unit2, 1), c2(unit2, 1),
+ h1_seq(unit1, seq_length)
real*8 input1(dim_x, 1), input2(unit1, 1)
! iteration index
integer di, dj
!*** main code
!lstm layer 1
h1 = 0
c1 = 0
do di = 1, seq_length
input1(:, 1) = input_seq_scaled(:, di)
call update_state(input1, h1, c1,
+ Wx1, Wh1, b1, dim_x, unit1, matrix_for_backprop_1)
h1_seq(:, di) = h1(:, 1)
enddo
! lstm layer 2
h2=0
c2=0
do dj = 1, seq_length
input2(:, 1) = h1_seq(:, dj)
call update_state(input2, h2, c2, Wx2,
+ Wh2, b2, unit1, unit2,matrix_for_backprop_2)
enddo
! Dense layer and get output stress
stress_3d_scaled = 0
call dense(stress_3d_scaled, h2, Wd, bd, dim_y, unit2,
+ matrix_for_backprop_3)
return
end subroutine NN_prediction