RLPack
 
Loading...
Searching...
No Matches
rlpack.models._mlp_feature_extractor._MlpFeatureExtractor Class Reference

This class is a PyTorch Model implementing the MLP based feature extractor for 1-D or 2-D state values. More...

+ Inheritance diagram for rlpack.models._mlp_feature_extractor._MlpFeatureExtractor:
+ Collaboration diagram for rlpack.models._mlp_feature_extractor._MlpFeatureExtractor:

Public Member Functions

def __init__ (self, int sequence_length, List[int] hidden_sizes, Activation activation=pytorch.nn.ReLU(), float dropout=0.5)
 Initialize MlpFeatureExtractor model. More...
 
pytorch.Tensor forward (self, pytorch.Tensor x)
 The forwards method of the nn.Module. More...
 

Data Fields

 activation
 The input activation function. More...
 
 dropout
 The input dropout probability. More...
 
 hidden_sizes
 The input hidden sizes for each layer. More...
 
 linear_module_dict
 The ModuleDict of Linear Layers. More...
 
 num_blocks
 The number of layers/blocks of MLP. More...
 
 sequence_length
 The input sequence length of expected tensor. More...
 

Detailed Description

This class is a PyTorch Model implementing the MLP based feature extractor for 1-D or 2-D state values.

Constructor & Destructor Documentation

◆ __init__()

def rlpack.models._mlp_feature_extractor._MlpFeatureExtractor.__init__ (   self,
int  sequence_length,
List[int]  hidden_sizes,
Activation   activation = pytorch.nn.ReLU(),
float   dropout = 0.5 
)

Initialize MlpFeatureExtractor model.

Parameters
sequence_lengthint: The sequence length of the expected tensor.
hidden_sizesList[int]: The list of hidden sizes for each layer.
activationActivation: The activation function class for the model. Must be an initialized activation object from PyTorch's nn (torch.nn) module.
dropoutfloat: The dropout to be used in the final Linear (FC) layer.

Member Function Documentation

◆ forward()

pytorch.Tensor rlpack.models._mlp_feature_extractor._MlpFeatureExtractor.forward (   self,
pytorch.Tensor  x 
)

The forwards method of the nn.Module.

Parameters
xpytorch.Tensor: The model input.
Returns
pytorch.Tensor: The model output (logits).

Field Documentation

◆ activation

rlpack.models._mlp_feature_extractor._MlpFeatureExtractor.activation

The input activation function.

◆ dropout

rlpack.models._mlp_feature_extractor._MlpFeatureExtractor.dropout

The input dropout probability.

◆ hidden_sizes

rlpack.models._mlp_feature_extractor._MlpFeatureExtractor.hidden_sizes

The input hidden sizes for each layer.

◆ linear_module_dict

rlpack.models._mlp_feature_extractor._MlpFeatureExtractor.linear_module_dict

The ModuleDict of Linear Layers.

◆ num_blocks

rlpack.models._mlp_feature_extractor._MlpFeatureExtractor.num_blocks

The number of layers/blocks of MLP.

◆ sequence_length

rlpack.models._mlp_feature_extractor._MlpFeatureExtractor.sequence_length

The input sequence length of expected tensor.