Nodes of different colours represent the following:
Solid arrows point from a submodule to the (sub)module which it is
descended from. Dashed arrows point from a module or program unit to
modules which it uses.
Where possible, edges connecting nodes are
given different colours to make them easier to distinguish in
large graphs.
Nodes of different colours represent the following:
Solid arrows point from a submodule to the (sub)module which it is
descended from. Dashed arrows point from a module or program unit to
modules which it uses.
Where possible, edges connecting nodes are
given different colours to make them easier to distinguish in
large graphs.
A dense (fully-connected) output layer for a feed-forward neural network.
An output layer is just a dense layer with separate activation functions
for each node.
Components
num_parameters :
integer– The total number of free parameters in the model. This should
always be set by the `constructor` procedure of the derived type.
– Inherited from DenseLayer
num_parameters_mask :
integer– The number of parameters that are not kept frozen by `mask`.
– Inherited from DenseLayer
mask :
logical (dim: (:))– A logical array specifying, for each free parameter, whether it
should be optimized or not.
– Inherited from DenseLayer
batchsize :
integer– The number of samples that can pass concurrently through the layer.
– Inherited from DenseLayer
num_forward_passes :
integer– Inherited from DenseLayer
num_backward_passes :
integer– Inherited from DenseLayer
num_nodes_input :
integer– The number of input nodes to this layer.
– Inherited from DenseLayer
num_nodes :
integer– The number of nodes in this layer.
– Inherited from DenseLayer
idx :
integer– Layer index.
– Inherited from DenseLayer
weights :
real(DP) (dim: (:,:))– Connections to preceding layer nodes.
– Inherited from DenseLayer
biases :
real(DP) (dim: (:))– Bias values for shifting each node's offset.
– Inherited from DenseLayer
dw :
real(DP) (dim: (:,:))– Gradients of `weights`.
– Inherited from DenseLayer
db :
real(DP) (dim: (:))– Gradients of `biases`.
– Inherited from DenseLayer
z :
real(DP) (dim: (:,:))– Node values before activation. Required for backpropagation.
– Inherited from DenseLayer
dz_dq :
real(DP) (dim: (:,:))– Derivatives of the unactivated node values wrt a single coordinate.
– Inherited from DenseLayer
da_dq :
real(DP) (dim: (:,:))– Derivatives of the activated node values wrt a single coordinate.
– Inherited from DenseLayer
x :
real(DP) (dim: (:,:))– The input to the layer. Dimensions are inputsize x batchsize.
– Inherited from DenseLayer
a :
real(DP) (dim: (:,:))– Layer output.
– Inherited from DenseLayer
grad :
real(DP) (dim: (:,:))– doutput/dinput.
– Inherited from DenseLayer
dgrad_dq :
real(DP) (dim: (:,:))– doutput/dinput/dx
– Inherited from DenseLayer
lsaturation_check :
logical– Inherited from DenseLayer
forward_ptr :
procedure– Pointer for delegating the forward pass to the correct implementation.
We have an OpenMP-parallel and a non-parallel forward pass implementation.
The serial implementation is more efficient for small batchsizes.
We align the pointer whenever reallocate_inputlayer is called,
which is usually only once.
– Inherited from DenseLayer
backward_ptr :
procedure– Pointer for delegating the backward pass. See forward_ptr
for details.
– Inherited from DenseLayer
f_act_single :
type(ActivationFunctionPtr) (dim: (:))– Activation functions for each single node.
Nodes of different colours represent the following:
Solid arrows point from a derived type to the parent type which it
extends. Dashed arrows point from a derived type to the other
types it contains as a components, with a label listing the name(s) of
said component(s).
Where possible, edges connecting nodes are
given different colours to make them easier to distinguish in
large graphs.
Nodes of different colours represent the following:
Solid arrows point from a procedure to one which it calls. Dashed
arrows point from an interface to procedures which implement that interface.
This could include the module procedures in a generic interface or the
implementation in a submodule of an interface in a parent module.
Where possible, edges connecting nodes are
given different colours to make them easier to distinguish in
large graphs.
Nodes of different colours represent the following:
Solid arrows point from a procedure to one which it calls. Dashed
arrows point from an interface to procedures which implement that interface.
This could include the module procedures in a generic interface or the
implementation in a submodule of an interface in a parent module.
Where possible, edges connecting nodes are
given different colours to make them easier to distinguish in
large graphs.
x :
real(DP) (dim: (self%num_nodes_input,self%batchsize)) [in]– The activations of the preceeding layer.
dx_dq :
real(DP) (dim: (self%num_nodes_input,self%batchsize)) [in]– Derivative of the preceeding layer activations `x` with respect to some
variable q.
Perform a batchwise backward pass for a dense layer
including the contributions of the input gradient.
All math is documented at the relevant places.
Notation:
* = Hadamard (element-wise) product
. = Dot product (matrix multiplication)
= da2/db2 * da3/da2dx + da3/da2 * d^2a2/db2dx
= da3/da2dx * f'(z2) + da3/da2 * f''(z2) * dz2/dx