Module containing the implementation of the Glorot initialiser
This module implements Glorot (Xavier) initialisation, designed to maintain variance of gradients through layers with sigmoid/tanh.
Mathematical operation:
Uniform variant:
Normal variant:
where is fan-in, is fan-out.
Rationale: Maintains variance across layers, prevents vanishing/exploding gradients in deep networks
Best for: Tanh, Sigmoid, Softmax activations Reference: Glorot & Bengio (2010), AISTATS
Interface for the Glorot normal initialiser
Glorot normal initialiser object
Interface for the Glorot uniform initialiser
Glorot uniform initialiser object
Type for the Glorot initialiser (normal)
| Type | Visibility | Attributes | Name | Initial | |||
|---|---|---|---|---|---|---|---|
| real(kind=real32), | public | :: | mean | = | 1._real32 |
Scale, mean, and standard deviation of the initialiser |
|
| character(len=20), | public | :: | name |
Name of the initialiser |
|||
| real(kind=real32), | public | :: | scale | = | 1._real32 |
Scale, mean, and standard deviation of the initialiser |
|
| real(kind=real32), | public | :: | std | = | 0.01_real32 |
Scale, mean, and standard deviation of the initialiser |
| private module function initialiser_normal_setup () | Interface for the Glorot normal initialiser |
| procedure, public, pass(this) :: initialise => glorot_normal_initialise | Initialise the weights and biases using the Glorot normal distribution |
Type for the Glorot initialiser (uniform)
| Type | Visibility | Attributes | Name | Initial | |||
|---|---|---|---|---|---|---|---|
| real(kind=real32), | public | :: | mean | = | 1._real32 |
Scale, mean, and standard deviation of the initialiser |
|
| character(len=20), | public | :: | name |
Name of the initialiser |
|||
| real(kind=real32), | public | :: | scale | = | 1._real32 |
Scale, mean, and standard deviation of the initialiser |
|
| real(kind=real32), | public | :: | std | = | 0.01_real32 |
Scale, mean, and standard deviation of the initialiser |
| private module function initialiser_uniform_setup () | Interface for the Glorot uniform initialiser |
| procedure, public, pass(this) :: initialise => glorot_uniform_initialise | Initialise the weights and biases using the Glorot uniform distribution |
Initialise the weights and biases using the Glorot normal distribution
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(glorot_normal_init_type), | intent(inout) | :: | this |
Instance of the Glorot initialiser |
||
| real(kind=real32), | intent(out), | dimension(..) | :: | input |
Weights to initialise |
|
| integer, | intent(in), | optional | :: | fan_in |
Number of input and output units |
|
| integer, | intent(in), | optional | :: | fan_out |
Number of input and output units |
|
| integer, | intent(in), | optional, | dimension(:) | :: | spacing |
Spacing of the input and output units (not used here, included for compatibility) |
Initialise the weights and biases using the Glorot uniform distribution
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(glorot_uniform_init_type), | intent(inout) | :: | this |
Instance of the Glorot initialiser |
||
| real(kind=real32), | intent(out), | dimension(..) | :: | input |
Weights and biases to initialise |
|
| integer, | intent(in), | optional | :: | fan_in |
Number of input and output units |
|
| integer, | intent(in), | optional | :: | fan_out |
Number of input and output units |
|
| integer, | intent(in), | optional, | dimension(:) | :: | spacing |
Spacing of the input and output units (not used) |