mlprimitives.candidates.timeseries.cyclegan module¶
-
class
mlprimitives.candidates.timeseries.cyclegan.
CycleGAN
(shape, encoder_input_shape, generator_input_shape, critic_x_input_shape, critic_z_input_shape, layers_encoder, layers_generator, layers_critic_x, layers_critic_z, optimizer, learning_rate=0.0005, epochs=2000, latent_dim=20, batch_size=64, iterations_critic=5, **hyperparameters)[source]¶ Bases:
object
CycleGAN class
-
fit
(X, **kwargs)[source]¶ Fit the CycleGAN.
- Parameters
X (ndarray) – N-dimensional array containing the input training sequences for the model.
-
predict
(X)[source]¶ Predict values using the initialized object.
- Parameters
X (ndarray) – N-dimensional array containing the input sequences for the model.
- Returns
- ndarray:
N-dimensional array containing the reconstructions for each input sequence.
- ndarray:
N-dimensional array containing the critic scores for each input sequence.
- Return type
typle
-
-
class
mlprimitives.candidates.timeseries.cyclegan.
RandomWeightedAverage
(batch_size)[source]¶ Bases:
tensorflow.python.keras.engine.base_layer.Layer
-
call
(inputs, **kwargs)[source]¶ This is where the layer’s logic lives.
- Parameters
inputs – Input tensor, or list/tuple of input tensors.
**kwargs – Additional keyword arguments.
- Returns
A tensor or list/tuple of tensors.
-
compute_output_shape
(input_shape)[source]¶ Computes the output shape of the layer.
If the layer has not been built, this method will call build on the layer. This assumes that the layer will later be used with inputs that match the input shape provided here.
- Parameters
input_shape – Shape tuple (tuple of integers) or list of shape tuples (one per output tensor of the layer). Shape tuples can include None for free dimensions, instead of an integer.
- Returns
An input shape tuple.
-
-
mlprimitives.candidates.timeseries.cyclegan.
score_anomalies
(y, y_hat, critic, score_window=10, smooth_window=200)[source]¶ Compute an array of anomaly scores.
Anomaly scores are calculated using a combination of reconstruction error and critic score.
- Parameters
y (ndarray) – Ground truth.
y_hat (ndarray) – Predicted values. Each timestamp has multiple predictions.
critic (ndarray) – Critic score. Each timestamp has multiple critic scores.
score_window (int) – Optional. Size of the window over which the scores are calculated. If not given, 10 is used.
smooth_window (int) – Optional. Size of window over which smoothing is applied. If not given, 200 is used.
- Returns
Array of anomaly scores.
- Return type
ndarray