osl_dynamics.inference.initializers#
Initializers for TensorFlow layers.
Attributes#
Classes#
Initialize weights to given value. |
|
Initialize weights to given value with random noise added. |
|
Initialize weights to a flattened cholesky factor of identity matrices. |
|
Normal identity cholesky initializer. |
|
Normal correlation cholesky initializer. |
|
Initializer for diagonal matrices with a normal error added. |
|
Initialize weights to another Tensor's value. |
Functions#
|
Re-initializes the weights in a particular layer. |
|
Re-initialize the weights in a model. |
Module Contents#
- class osl_dynamics.inference.initializers.WeightInitializer(initial_value)[source]#
Bases:
tensorflow.keras.initializers.InitializerInitialize weights to given value.
- Parameters:
initial_value (np.ndarray) – Value to initialise weights to. Note, the shape is not checked.
- class osl_dynamics.inference.initializers.RandomWeightInitializer(initial_value, std)[source]#
Bases:
tensorflow.keras.initializers.InitializerInitialize weights to given value with random noise added.
- Parameters:
initial_value (np.ndarray) – Value to initialise weights to. Note, the shape is not checked.
std (float) – Standard deviation of the noise to add.
- class osl_dynamics.inference.initializers.IdentityCholeskyInitializer[source]#
Bases:
tensorflow.keras.initializers.InitializerInitialize weights to a flattened cholesky factor of identity matrices.
- class osl_dynamics.inference.initializers.NormalIdentityCholeskyInitializer(std)[source]#
Bases:
tensorflow.keras.initializers.InitializerNormal identity cholesky initializer.
Initialize weights to a flattened cholesky factor of identity matrices with a normal error added to the diagonal.
- Parameters:
std (float) – Standard deviation of the error to add.
- class osl_dynamics.inference.initializers.NormalCorrelationCholeskyInitializer(std)[source]#
Bases:
tensorflow.keras.initializers.InitializerNormal correlation cholesky initializer.
Initialize weights to a flattened cholesky factor of correlation matrices with a normal error added to the flattened cholesky factor.
- Parameters:
mean (float) – Mean of the error to add.
std (float) – Standard deviation of the error to add.
- class osl_dynamics.inference.initializers.NormalDiagonalInitializer(std)[source]#
Bases:
tensorflow.keras.initializers.InitializerInitializer for diagonal matrices with a normal error added.
- Parameters:
std (float) – Standard deviation of the error to add.
- class osl_dynamics.inference.initializers.CopyTensorInitializer(tensor)[source]#
Bases:
tensorflow.keras.initializers.InitializerInitialize weights to another Tensor’s value.
- Parameters:
tensor (tf.Tensor) – Tensor to copy.
- osl_dynamics.inference.initializers.reinitialize_layer_weights(layer)[source]#
Re-initializes the weights in a particular layer.
- Parameters:
layer (tf.keras.layers.Layer) – Layer to initialize weights for.
- Return type:
None
Note
This function relies on each layer having an attribute for the initializer. Standard TensorFlow layers have this. You must specify a
self.*_initializerattribute in any custom layer, otherwise this function will break.
- osl_dynamics.inference.initializers.reinitialize_model_weights(model, keep=None)[source]#
Re-initialize the weights in a model.
- Parameters:
model (tf.keras.Model) – Model to re-initialize weights for.
keep (list, optional) – List of
strcontaining names for layers to not reinitialize.
- Return type:
None