yamle.models.rnn module#

class yamle.models.rnn.RNNModel(hidden_dim, width_multiplier, depth, *args, **kwargs)[source]#

Bases: BaseModel

This class is used to create a LSTM model with the given parameters.

Parameters:
  • hidden_dim (int) – The dimension of the hidden layers.

  • width_multiplier (int) – The width multiplier for the hidden layers.

  • depth (int) – The number of hidden layers.

tasks = ['regression', 'classification']#
forward(x, staged_output=False, input_kwargs={}, output_kwargs={})[source]#

The forward function of the model.

Parameters:
  • x (torch.Tensor) – The input tensor.

  • staged_output (bool) – Whether to return the output of each layer. Defaults to False.

  • input_kwargs (Dict[str, Any]) – The kwargs for the input layer.

  • output_kwargs (Dict[str, Any]) – The kwargs for the output layer.

Return type:

Union[Tensor, Tuple[Tensor, List[Tensor]]]

final_layer(x, **output_kwargs)[source]#

This function is used to get the final layer output.

Return type:

Tensor

add_method_specific_layers(method, **kwargs)[source]#

This method is used to add method specific layers to the model.

Parameters:

method (str) – The method to use.

Return type:

None

static add_specific_args(parent_parser)[source]#

This method is used to add the model specific arguments to the parent parser.

Return type:

ArgumentParser

training: bool#
class yamle.models.rnn.RNNAutoEncoderModel(hidden_dim, width_multiplier, encoder_depth, decoder_depth, *args, **kwargs)[source]#

Bases: BaseModel

This class is used to create a LSTM model with the given parameters.

This is an autoencoder model, so the input and output dimensions are the same. The encoder consists of LSTM layers, while the decoder consists of LSTM layers. The encoder’s last hidden state is repeated and used as the input to the decoder. Then all the hidden states of the decoder are processed through a linear layer to get the two times the input dimension, one for mean and one for variance.

Parameters:
  • hidden_dim (int) – The dimension of the hidden layers.

  • width_multiplier (int) – The width multiplier for the hidden layers.

  • encoder_depth (int) – The number of hidden layers for the encoder.

  • decoder_depth (int) – The number of hidden layers for the decoder.

tasks = ['reconstruction']#
forward(x, staged_output=False, input_kwargs={}, output_kwargs={})[source]#

The forward function of the model.

Parameters:
  • x (torch.Tensor) – The input tensor.

  • staged_output (bool) – Whether to return the output of each layer. Defaults to False.

  • input_kwargs (Dict[str, Any]) – The kwargs for the input layer.

  • output_kwargs (Dict[str, Any]) – The kwargs for the output layer.

Return type:

Union[Tensor, Tuple[Tensor, List[Tensor]]]

final_layer(x, **output_kwargs)[source]#

This function is used to get the final layer output.

Return type:

Tensor

static add_specific_args(parent_parser)[source]#

This method is used to add the model specific arguments to the parent parser.

Return type:

ArgumentParser

training: bool#
class yamle.models.rnn.InputRepeater(*args, **kwargs)[source]#

Bases: Module

This class repeats the input for the given number of times.

forward(x, T)[source]#

This method repeats the input for the given number of times.

Parameters:
  • x (torch.Tensor) – The input tensor.

  • T (int) – The number of times to repeat the input.

Return type:

Tensor

training: bool#