stable_learning_control.algos.tf2.common.helpers
Several TensorFlow helper functions.
Functions
|
Sets the computational device given a device type. |
|
Create a multi-layered perceptron using TensorFlow. |
|
Returns the total number of parameters of a TensorFlow module. |
|
Rescale normalized data (i.e. between |
|
Prints a full summary of all the layers of a TensorFlow model. |
Module Contents
- stable_learning_control.algos.tf2.common.helpers.set_device(device_type='cpu')[source]
Sets the computational device given a device type.
- stable_learning_control.algos.tf2.common.helpers.mlp(sizes, activation, output_activation=None, name='')[source]
Create a multi-layered perceptron using TensorFlow.
- Parameters:
sizes (list) – The size of each of the layers.
activation (union[
tf.keras.activations
,str
]) – The activation function used for the hidden layers.output_activation (union[
tf.keras.activations
,str
], optional) – The activation function used for the output layers. Defaults toNone
.name (str, optional) – A nameprefix that is added before the layer name. Defaults to an empty string.
- Returns:
The multi-layered perceptron.
- Return type:
- stable_learning_control.algos.tf2.common.helpers.count_vars(module)[source]
Returns the total number of parameters of a TensorFlow module.
- Parameters:
module (Union[tf.keras.Model, tf.module]) – The TensorFlow model.
- Returns:
The total number of parameters inside the module.
- Return type:
numpy.int64
- stable_learning_control.algos.tf2.common.helpers.rescale(data, min_bound, max_bound)[source]
Rescale normalized data (i.e. between
-1
and1
) to a desired range.- Parameters:
data (Union[numpy.ndarray, list]) – Normalized input data.
min_bound (Union[numpy.ndarray, list]) – Array containing the minimum value of the desired range.
max_bound (Union[numpy.ndarray, list]) – Array containing the maximum value of the desired range.
- Returns:
- Array which has it values scaled between the min and max
boundaries.
- Return type:
- stable_learning_control.algos.tf2.common.helpers.full_model_summary(model)[source]
Prints a full summary of all the layers of a TensorFlow model.
- Parameters:
layer (
tf.keras.layers
) – The model to print the full summary of.