@@ -15,7 +15,7 @@ module nf_layer_constructors
1515 flatten, &
1616 input, &
1717 linear2d, &
18- locally_connected1d , &
18+ locally_connected , &
1919 maxpool, &
2020 reshape, &
2121 self_attention, &
@@ -154,6 +154,38 @@ end function conv2d
154154 end interface conv
155155
156156
157+ interface locally_connected
158+
159+ module function locally_connected1d (filters , kernel_size , activation ) result(res)
160+ ! ! 1-d locally connected network constructor
161+ ! !
162+ ! ! This layer is for building 1-d locally connected network.
163+ ! ! Although the established convention is to call these layers 1-d,
164+ ! ! the shape of the data is actually 2-d: image width,
165+ ! ! and the number of channels.
166+ ! ! A locally connected 1d layer must not be the first layer in the network.
167+ ! !
168+ ! ! Example:
169+ ! !
170+ ! ! ```
171+ ! ! use nf, only :: locally_connected1d, layer
172+ ! ! type(layer) :: locally_connected1d_layer
173+ ! ! locally_connected1d_layer = dense(filters=32, kernel_size=3)
174+ ! ! locally_connected1d_layer = dense(filters=32, kernel_size=3, activation='relu')
175+ ! ! ```
176+ integer , intent (in ) :: filters
177+ ! ! Number of filters in the output of the layer
178+ integer , intent (in ) :: kernel_size
179+ ! ! Width of the convolution window, commonly 3 or 5
180+ class(activation_function), intent (in ), optional :: activation
181+ ! ! Activation function (default sigmoid)
182+ type (layer) :: res
183+ ! ! Resulting layer instance
184+ end function locally_connected1d
185+
186+ end interface locally_connected
187+
188+
157189 interface maxpool
158190
159191 module function maxpool1d (pool_width , stride ) result(res)
@@ -290,33 +322,6 @@ module function flatten() result(res)
290322 ! ! Resulting layer instance
291323 end function flatten
292324
293- module function locally_connected1d (filters , kernel_size , activation ) result(res)
294- ! ! 1-d locally connected network constructor
295- ! !
296- ! ! This layer is for building 1-d locally connected network.
297- ! ! Although the established convention is to call these layers 1-d,
298- ! ! the shape of the data is actually 2-d: image width,
299- ! ! and the number of channels.
300- ! ! A locally connected 1d layer must not be the first layer in the network.
301- ! !
302- ! ! Example:
303- ! !
304- ! ! ```
305- ! ! use nf, only :: locally_connected1d, layer
306- ! ! type(layer) :: locally_connected1d_layer
307- ! ! locally_connected1d_layer = dense(filters=32, kernel_size=3)
308- ! ! locally_connected1d_layer = dense(filters=32, kernel_size=3, activation='relu')
309- ! ! ```
310- integer , intent (in ) :: filters
311- ! ! Number of filters in the output of the layer
312- integer , intent (in ) :: kernel_size
313- ! ! Width of the convolution window, commonly 3 or 5
314- class(activation_function), intent (in ), optional :: activation
315- ! ! Activation function (default sigmoid)
316- type (layer) :: res
317- ! ! Resulting layer instance
318- end function locally_connected1d
319-
320325 module function linear2d (out_features ) result(res)
321326 ! ! Rank-2 (sequence_length, out_features) linear layer constructor.
322327 ! ! sequence_length is determined at layer initialization, based on the
0 commit comments