engine.model.Model#
- class Model(*args, **kwargs)[source]#
Bases:
Module
Class of interface for models
Initialize internal Module state, shared by both nn.Module and ScriptModule.
Methods
Returns the configured optimizer for training the network
Direct network pass
Loads network weights from a file
Loss calculation function
Returns the network's predictions based on the input data
Saves network weights
Network test step
Network training step
Network validation step
Attributes
training
- configure_optimizers() Optimizer [source]#
Returns the configured optimizer for training the network
- forward(X: Tensor) Any [source]#
Direct network pass
This method must be overridden in child classes.
- Parameters:
X (torch.Tensor) – Input data
- Raises:
NotImplementedError – This method is not implemented.
- Returns:
Result of the network operation
- Return type:
Any
- load_params(name: str) None [source]#
Loads network weights from a file
The file must be in the
nets
folder and end with.params
- Parameters:
name (str) – Parameters file name.
- loss(preds: Any, labels: Any) Tensor [source]#
Loss calculation function
This method must be overridden in child classes.
- Parameters:
preds (Any) – Predictions made by a neural network.
labels (Any) – Ground truth.
- Raises:
NotImplementedError – This method is not implemented.
- Returns:
Value of losses
- Return type:
- predict(X: Tensor) Tensor [source]#
Returns the network’s predictions based on the input data
- Parameters:
X (torch.Tensor) – Input data.
- Returns:
Network Predictions.
- Return type:
- save_params(name: str) None [source]#
Saves network weights
- Parameters:
name (str, optional) – Parameters file name. The file will be saved to the
nets
folder.
- test_step(batch: Tuple[Tensor, Tensor]) Tensor [source]#
Network test step
- Parameters:
batch (Tuple[torch.Tensor, torch.Tensor]) –
Training data. Contains:
Input data
Labels
- Returns:
Value of losses
- Return type:
- training_step(batch: Tuple[Tensor, Tensor]) Tensor [source]#
Network training step
- Parameters:
batch (Tuple[torch.Tensor, torch.Tensor]) –
Training data. Contains:
Input data
Labels
- Returns:
Value of losses
- Return type:
- validation_step(batch: Tuple[Tensor, Tensor]) Tensor [source]#
Network validation step
- Parameters:
batch (Tuple[torch.Tensor, torch.Tensor]) –
Training data. Contains:
Input data
Labels
- Returns:
Value of losses
- Return type: