NeSy4PPM.Training package

Submodules

NeSy4PPM.Training.Modulator module

class NeSy4PPM.Training.Modulator.Modulator(*args, **kwargs)

Bases: Layer

build(input_shape)
call(x)

Forward pass of the modulator layer.

Splits the input into different representation vectors, computes element-wise products, concatenates them, and applies learned weights and biases.

Parameters:

x (tf.Tensor) – Input tensor with shape (batch_size, time_steps, features).

Returns:

Modulated tensor with shape (batch_size, time_steps, features).

Return type:

tf.Tensor

compute_output_shape(input_shape)
get_config()

Returns the config of the object.

An object config is a Python dictionary (serializable) containing the information needed to re-instantiate it.

NeSy4PPM.Training.train_common module

class NeSy4PPM.Training.train_common.CustomTransformer(*args, **kwargs)

Bases: Layer

Custom Transformer block consisting of multi-head attention and feed-forward layers.

call(inputs, mask=None, *args, **kwargs)

Forward pass of the CustomTransformer layer.

Parameters:
  • inputs (tf.Tensor) – Input tensor.

  • mask (tf.Tensor, optional) – Attention mask.

Returns:

Output tensor after attention and feed-forward layers.

Return type:

tf.Tensor

get_config()

Return the config dictionary for recreating this layer.

Returns:

Configuration parameters.

Return type:

dict

NeSy4PPM.Training.train_common.create_checkpoints_path(log_name, model_type, output_folder)

Create a directory path and filename pattern for model checkpoints.

Parameters:
  • log_name (str) – Name of the log.

  • model (NN_model) – Enum representing the model type.

  • model_type (str) – Specific model type (e.g., ‘LSTM’, ‘Transformer’).

  • encoder (Encodings) – Enum representing the encoding method.

  • output_folder (Path) – Base output folder path.

Returns:

Full path pattern for saving checkpoint files.

Return type:

str

NeSy4PPM.Training.train_common.plot_loss(history, dir_name)

Plot and save the training and validation loss curves.

Parameters:
  • history (keras.callbacks.History) – Keras training history object.

  • dir_name (str or Path) – Directory to save the plot image.

NeSy4PPM.Training.train_model module

NeSy4PPM.Training.train_model.train(log_data: LogData, model_arch, encoder: Encodings, output_folder: Path, X, y_a, y_g=None)

Module contents