osl_dynamics.inference.layers.ParameterLayer#
- class osl_dynamics.inference.layers.ParameterLayer(shape, initializer=None, *, initial_value=None, learn=True, regularizer=None, **kwargs)#
Bases:
tensorflow.keras.layers.LayerLearnable parameter.
The parameter is stored as an unconstrained weight, the kernel. The value of the parameter is calculated from the kernel with
transform, which subclasses override to constrain the value (e.g. to positive definite matrices).- Parameters:
- shapetuple
Shape of the kernel.
- initializercallable, optional
Called with no arguments to draw a random kernel. Used when
initial_valueis not passed.- initial_valuenp.ndarray, optional
Initial value of the parameter.
- learnbool, optional
Should the parameter be trainable?
- regularizercallable, optional
Called with the value of the parameter to calculate the regularization.
- transform(kernel)#
Calculate the value of the parameter from the kernel.
- Parameters:
- kerneltf.Tensor
Trainable tensor of the layer.
- Returns:
- valuetf.Tensor
Value of the parameter.
- inverse_transform(value)#
Calculate the kernel from the value of the parameter.
- Parameters:
- valuenp.ndarray
Value of the parameter.
- Returns:
- kernelnp.ndarray
Kernel that gives the value.
- value()#
Value of the parameter.
- Returns:
- valuetf.Tensor
Transform of the kernel.
- assign(value, update_initializer=True)#
Set the value of the parameter.
- Parameters:
- valuenp.ndarray
Value of the parameter.
- update_initializerbool, optional
Should
resetset the parameter to this value?
- reset()#
Set the kernel to its initial value or a new random value.
- regularization()#
Regularization of the parameter.
- Returns:
- regularizationtf.Tensor
Scalar.
- summary_rows()#
Rows for the layer in the summary of a model.
- Returns:
- rowslist of tuple
(name, details, learned by, number of learned values)for each row.