mdae package

Submodules

mdae.train_mdae module

Module containing the TrainMDAE class and the command line interface.

class mdae.train_mdae.TrainMDAE(input_train_npy_path: str, output_model_pth_path: str, input_model_pth_path: str | None = None, output_train_data_npz_path: str | None = None, output_performance_npz_path: str | None = None, properties: Dict | None = None, **kwargs)[source]

Bases: BiobbObject

biobb_pytorch TrainMDAE
Train a Molecular Dynamics AutoEncoder (MDAE) PyTorch model.
Train a Molecular Dynamics AutoEncoder (MDAE) PyTorch model, the resulting Auto-associative Neural Network (AANN) can be applied to reduce the dimensionality of molecular dynamics data and analyze the dynamic properties of the system.
Parameters:
  • input_train_npy_path (str) – Path to the input train data file. File type: input. Sample file. Accepted formats: npy (edam:format_4003).

  • output_model_pth_path (str) –

    Path to the output model file. File type: output. Sample file. Accepted formats: pth (edam:format_2333).

  • input_model_pth_path (str) (Optional) –

    Path to the input model file. File type: input. Sample file. Accepted formats: pth (edam:format_2333).

  • output_train_data_npz_path (str) (Optional) –

    Path to the output train data file. File type: output. Sample file. Accepted formats: npz (edam:format_4003).

  • output_performance_npz_path (str) (Optional) –

    Path to the output performance file. File type: output. Sample file. Accepted formats: npz (edam:format_4003).

  • properties (dict - Python dictionary object containing the tool parameters, not input/output files) –

    • latent_dimensions (int) - (2) min dimensionality of the latent space.

    • num_layers (int) - (4) number of layers in the encoder/decoder (4 to encode and 4 to decode).

    • num_epochs (int) - (100) number of epochs (iterations of whole dataset) for training.

    • lr (float) - (0.0001) learning rate.

    • lr_step_size (int) - (100) Period of learning rate decay.

    • gamma (float) - (0.1) Multiplicative factor of learning rate decay.

    • checkpoint_interval (int) - (25) number of epochs interval to save model checkpoints o 0 to disable.

    • output_checkpoint_prefix (str) - (“checkpoint_epoch”) prefix for the checkpoint files.

    • partition (float) - (0.8) 0.8 = 80% partition of the data for training and validation.

    • batch_size (int) - (1) number of samples/frames per batch.

    • log_interval (int) - (10) number of epochs interval to log the training progress.

    • input_dimensions (int) - (None) input dimensions by default it should be the number of features in the input data (number of atoms * 3 corresponding to x, y, z coordinates).

    • output_dimensions (int) - (None) output dimensions by default it should be the number of features in the input data (number of atoms * 3 corresponding to x, y, z coordinates).

    • loss_function (str) - (“MSELoss”) Loss function to be used. Values: MSELoss, L1Loss, SmoothL1Loss, BCELoss, BCEWithLogitsLoss, CrossEntropyLoss, CTCLoss, NLLLoss, KLDivLoss, PoissonNLLLoss, NLLLoss2d, CosineEmbeddingLoss, HingeEmbeddingLoss, MarginRankingLoss, MultiLabelMarginLoss, MultiLabelSoftMarginLoss, MultiMarginLoss, TripletMarginLoss, HuberLoss, SoftMarginLoss, MultiLabelSoftMarginLoss, CosineEmbeddingLoss, MultiMarginLoss, TripletMarginLoss, MarginRankingLoss, HingeEmbeddingLoss, CTCLoss, NLLLoss, PoissonNLLLoss, KLDivLoss, CrossEntropyLoss, BCEWithLogitsLoss, BCELoss, SmoothL1Loss, L1Loss, MSELoss.

    • optimizer (str) - (“Adam”) Optimizer algorithm to be used. Values: Adadelta, Adagrad, Adam, AdamW, SparseAdam, Adamax, ASGD, LBFGS, RMSprop, Rprop, SGD.

    • seed (int) - (None) Random seed for reproducibility.

Examples

This is a use case of how to use the building block from Python:

from biobb_pytorch.mdae.train_mdae import trainMDAE

prop = {
    'latent_dimensions': 2,
    'num_layers': 4,
    'num_epochs': 100,
    'lr': 0.0001,
    'checkpoint_interval': 25,
    'partition': 0.8,
    'batch_size': 1,
    'log_interval': 10,
    'input_dimensions': 3,
    'output_dimensions': 3,
    'loss_function': 'MSELoss',
    'optimizer': 'Adam'
}

trainMDAE(input_train_npy_path='/path/to/myInputData.npy',
          output_model_pth_path='/path/to/newModel.pth',
          input_model_pth_path='/path/to/oldModel.pth',
          output_train_data_npz_path='/path/to/newTrainData.npz',
          output_performance_npz_path='/path/to/newPerformance.npz',
          properties=prop)
Info:
evaluate_model(dataloader: DataLoader, loss_function: _Loss) Tuple[float, ndarray, ndarray][source]
launch() int[source]

Execute the TrainMDAE object.

train_model() Tuple[List[float], List[float], Dict, int][source]
training_step(dataloader: DataLoader, optimizer: Optimizer, loss_function: _Loss) Tuple[float, float][source]
mdae.train_mdae.main()[source]

Command line execution of this building block. Please check the command line documentation.

mdae.train_mdae.trainMDAE(input_train_npy_path: str, output_model_pth_path: str, input_model_pth_path: str | None = None, output_train_data_npz_path: str | None = None, output_performance_npz_path: str | None = None, properties: Dict | None = None, **kwargs) int[source]

Execute the TrainMDAE class and execute the launch() method.

mdae.apply_mdae module

Module containing the ApplyMDAE class and the command line interface.

class mdae.apply_mdae.ApplyMDAE(input_data_npy_path: str, input_model_pth_path: str, output_reconstructed_data_npy_path: str, output_latent_space_npy_path: str | None = None, properties: Dict | None = None, **kwargs)[source]

Bases: BiobbObject

biobb_pytorch ApplyMDAE
Apply a Molecular Dynamics AutoEncoder (MDAE) PyTorch model.
Apply a Molecular Dynamics AutoEncoder (MDAE) PyTorch model, the resulting denoised molecular dynamics or the reduced the dimensionality of molecular dynamics data can be used to analyze the dynamic properties of the system.
Parameters:
  • input_data_npy_path (str) –

    Path to the input data file. File type: input. Sample file. Accepted formats: npy (edam:format_4003).

  • input_model_pth_path (str) –

    Path to the input model file. File type: input. Sample file. Accepted formats: pth (edam:format_2333).

  • output_reconstructed_data_npy_path (str) –

    Path to the output reconstructed data file. File type: output. Sample file. Accepted formats: npy (edam:format_4003).

  • output_latent_space_npy_path (str) (Optional) –

    Path to the reduced dimensionality file. File type: output. Sample file. Accepted formats: npy (edam:format_4003).

  • properties (dict - Python dictionary object containing the tool parameters, not input/output files) –

    • batch_size (int) - (1) number of samples/frames per batch.

    • latent_dimensions (int) - (2) min dimensionality of the latent space.

    • num_layers (int) - (4) number of layers in the encoder/decoder (4 to encode and 4 to decode).

    • input_dimensions (int) - (None) input dimensions by default it should be the number of features in the input data (number of atoms * 3 corresponding to x, y, z coordinates).

    • output_dimensions (int) - (None) output dimensions by default it should be the number of features in the input data (number of atoms * 3 corresponding to x, y, z coordinates).

Examples

This is a use case of how to use the building block from Python:

from biobb_pytorch.mdae.apply_mdae import ApplyMDAE
prop = {
    'latent_dimensions': 2,
    'num_layers': 4
}
ApplyMDAE(input_data_npy_path='/path/to/myInputData.npy',
          output_reconstructed_data_npy_path='/path/to/newReconstructedData.npz',
          input_model_pth_path='/path/to/oldModel.pth',
          properties=prop).launch()
Info:
apply_model(dataloader: DataLoader) Tuple[ndarray, ndarray][source]
launch() int[source]

Execute the ApplyMDAE object.

mdae.apply_mdae.applyMDAE(input_data_npy_path: str, input_model_pth_path: str, output_reconstructed_data_npy_path: str, output_latent_space_npy_path: str | None = None, properties: Dict | None = None, **kwargs) int[source]

Execute the ApplyMDAE class and execute the launch() method.

mdae.apply_mdae.main()[source]

Command line execution of this building block. Please check the command line documentation.