gossipy.model.nn module#
Module contents#
- class gossipy.model.nn.AdaLine(dim)#
Bases:
gossipy.model.TorchModel
The Adaline perceptron model.
Implementation of the AdaLine perceptron model [], []. The model is a simple perceptron with a linear activation function.
- Parameters
dim (int) – The number of input features.
- forward(x)#
Defines the computation performed at every call.
Should be overridden by all subclasses.
Note
Although the recipe for forward pass needs to be defined within this function, one should call the
Module
instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.- Return type
- Parameters
x (torch.Tensor) –
- get_size()#
Returns the number of parameters of the model.
- Returns
The number of parameters of the model.
- Return type
- class gossipy.model.nn.LogisticRegression(input_dim, output_dim)#
Bases:
gossipy.model.TorchModel
Logistic regression model.
Implementation of the logistic regression model.
- Parameters
- forward(x)#
Defines the computation performed at every call.
Should be overridden by all subclasses.
Note
Although the recipe for forward pass needs to be defined within this function, one should call the
Module
instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.- Return type
- Parameters
x (torch.Tensor) –
- class gossipy.model.nn.TorchMLP(input_dim, output_dim, hidden_dims=(100, ), activation=<class 'torch.nn.modules.activation.ReLU'>)#
Bases:
gossipy.model.TorchModel
Multi-layer perceptron model.
Implementation of the multi-layer perceptron model. The model is composed of a sequence of linear layers with the specified activation function (same activation for all layers but the last one).
- Parameters
- forward(x)#
Defines the computation performed at every call.
Should be overridden by all subclasses.
Note
Although the recipe for forward pass needs to be defined within this function, one should call the
Module
instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.- Return type
- Parameters
x (torch.Tensor) –
- class gossipy.model.nn.TorchPerceptron(dim, activation=<class 'torch.nn.modules.activation.Sigmoid'>, bias=True)#
Bases:
gossipy.model.TorchModel
Perceptron model.
Implementation of the perceptron model by Rosenblatt [].
- Parameters
- forward(x)#
Defines the computation performed at every call.
Should be overridden by all subclasses.
Note
Although the recipe for forward pass needs to be defined within this function, one should call the
Module
instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.- Return type
- Parameters
x (torch.Tensor) –