yamle.models.convnet module#
- class yamle.models.convnet.ConvNetModel(conv_hidden_dims, linear_hidden_dims, normalization, activation='relu', *args, **kwargs)[source]#
Bases:
BaseModelThis class is used to create a convolutional model similar to LeNet.
It combines convolutional layers, followed each time by pooling layers, ended with fully connected layers.
The first input layer is a Convolution, followed by normalization and ReLU, otherwise we used the Conv2dNormActivation classes and LinearNormActivation classes. The output is only a linear layer, followed by the OutputActivation class.
- Parameters:
inputs_dim¶ (Tuple[int, int, int]) – The input dimensions.
conv_hidden_dims¶ (List[int]) – The dimensions of the convolutional hidden layers.
linear_hidden_dims¶ (List[int]) – The dimensions of the linear hidden layers.
outputs_dim¶ (int) – The dimension of the output.
normalization¶ (Optional[str]) – The normalization to use. Either ‘batch’, ‘layer’, ‘instance’ or None.
activation¶ (Optional[str]) – The activation to use. Either ‘relu’, ‘sigmoid’, ‘tanh’ or None.
task¶ (str) – The task to perform. Either ‘classification’ or ‘regression’. The task determined is softmax is used for the output layer.
- tasks = ['classification', 'regression']#
- forward(x, staged_output=False, input_kwargs={}, output_kwargs={})[source]#
This method is used to perform a forward pass through the model.
The input is expected to be of shape (batch_size, inputs_dim). The output is of shape (batch_size, outputs_dim).
- Parameters:
- 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.convnet.ResidualConvNetModel(inputs_dim, outputs_dim, task, conv_hidden_dims=[32, 128], linear_hidden_dims=[128, 128], normalization='batch')[source]#
Bases:
ConvNetModelThis class is used to create a residual convolutional network.
-
training:
bool#
-
training: