pyopmnearwell.ml.scaler_layers module#
Provide MinMax scaler layers for tensorflow.keras.
Warning: Tensorflow 2.17 and Keras 3.0 introduce many pylint errors, hence we disable linting completely. It is possible that the module is not functional at the moment.
- class ScalerLayer(*args, **kwargs)[source]#
Bases:
LayerMixIn to provide functionality for the Scaler Layer.
- min: Tensor#
- scalar: Tensor#
- build(input_shape)[source]#
Initialize scaling bounds when the layer is built.
not been initialized yet.
- set_weights(weights)[source]#
Set parameters of the scaling.
- Parameters:
- Raises:
ValueError -- If
feature_range[0] >= feature_range[1].- Return type:
None
- adapt(data)[source]#
Fit scaling bounds independently for each input feature.
each input feature.
- Parameters:
data (ArrayLike) -- Values used to fit the scaling extrema.
- Return type:
None
- property is_adapted#
Return whether the scaling parameters have been initialized.
- Returns:
Result produced by the operation.
- Return type:
Any
- property feature_range#
Return the target interval for each scaled feature.
- Returns:
Result produced by the operation.
- Return type:
Any
- property data_min#
Return the observed minimum for each feature.
- Returns:
Result produced by the operation.
- Return type:
Any
- property data_max#
Return the observed maximum for each feature.
- Returns:
Result produced by the operation.
- Return type:
Any
- class MinMaxScalerLayer(*args, **kwargs)[source]#
Bases:
ScalerLayer,LayerScales the input according to MinMaxScaling.
See https://scikit-learn.org/stable/modules/generated/sklearn.preprocessing.MinMaxScaler.html for an explanation of the transform.
- call(inputs)[source]#
Apply the layer transformation to an input tensor.
- Parameters:
inputs (tf.Tensor) -- Tensor values transformed by the layer.
- Returns:
Result produced by the operation.
- Return type:
tf.Tensor
- compute_output_shape(input_shape)[source]#
Return the unchanged output shape of the elementwise transformation.
- Parameters:
input_shape (Any) -- Shape of input tensors presented to the layer.
- Returns:
Result produced by the operation.
- Return type:
Any
- class MinMaxUnScalerLayer(*args, **kwargs)[source]#
Bases:
ScalerLayer,LayerUnscales the input by applying the inverse transform of
MinMaxScalerLayer.See https://scikit-learn.org/stable/modules/generated/sklearn.preprocessing.MinMaxScaler.html for an explanation of the transformation.
- call(inputs)[source]#
Apply the layer transformation to an input tensor.
- Parameters:
inputs (tf.Tensor) -- Tensor values transformed by the layer.
- Returns:
Result produced by the operation.
- Return type:
tf.Tensor
- compute_output_shape(input_shape)[source]#
Return the unchanged output shape of the elementwise transformation.
- Parameters:
input_shape (Any) -- Shape of input tensors presented to the layer.
- Returns:
Result produced by the operation.
- Return type:
Any