Skip to content

Commit 30e54e9

Browse files
committed
Back to 1D concept
I'll try with 1D with a state memory and the option to reset state for processing a new time series.
1 parent 0bbaa4a commit 30e54e9

File tree

2 files changed

+8
-9
lines changed

2 files changed

+8
-9
lines changed

src/nf/nf_rnn_layer.f90

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ module nf_rnn_layer
2020
integer :: output_size
2121

2222
real, allocatable :: weights(:,:)
23-
real, allocatable :: recurrent(:,:)
23+
real, allocatable :: recurrent(:)
2424
real, allocatable :: biases(:)
2525
real, allocatable :: z(:) ! matmul(x, w) + b
2626
real, allocatable :: state(:)

src/nf/nf_rnn_layer_submodule.f90

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -134,17 +134,13 @@ module subroutine init(self, input_shape)
134134
call random_normal(self % weights)
135135
self % weights = self % weights / self % input_size
136136

137-
! Recurrent weights are a 2-d square array of shape this layer size.
138-
! Each neuron is adjusted by each state times a recurrent weight.
139-
allocate(self % recurrent(self % output_size, self % output_size))
140-
call random_normal(self % recurrent)
141-
self % recurrent = self % recurrent / self % output_size
142-
143137
! Broadcast weights to all other images, if any.
144138
call co_broadcast(self % weights, 1)
145139

146-
allocate(self % state(self % output_size))
147-
self % state = 0
140+
allocate(self % recurrent(self % output_size))
141+
call random_normal(self % recurrent)
142+
self % recurrent = self % recurrent / self % input_size
143+
148144

149145
allocate(self % biases(self % output_size))
150146
self % biases = 0
@@ -155,6 +151,9 @@ module subroutine init(self, input_shape)
155151
allocate(self % z(self % output_size))
156152
self % z = 0
157153

154+
allocate(self % state(self % output_size))
155+
self % state = 0
156+
158157
allocate(self % dw(self % input_size, self % output_size))
159158
self % dw = 0
160159

0 commit comments

Comments
 (0)