model
_model
This file is a base class for the model.
- class scalr.nn.model._model.ModelBase[source]
Bases:
Module
Class for the model.
Contains different methods to make a forward() call, load, save weights and predict the data provided.
- classmethod get_default_params() dict [source]
Class method to get default params for model_config.
- get_predictions(dl: DataLoader, device: str = 'cpu')[source]
A function to get predictions from the dataloader.
sequential_model
This file is an implementation of a sequential model.
- class scalr.nn.model.sequential_model.SequentialModel(layers: list[int], dropout: float = 0, activation: str = 'ReLU', weights_init_zero: bool = False)[source]
Bases:
ModelBase
Class for Deep Neural Network model with linear layers.
- forward(x: Tensor) Tensor [source]
Pass input through the network.
- Parameters:
x – Tensor, shape [batch_size, layers[0]].
- Returns:
Output dict containing batched layers[-1]-dimensional vectors in [‘cls_output’] key.
- get_predictions(dl: DataLoader, device: str = 'cpu') Tuple[list[int], list[int], list[list[int]]] [source]
A function to get predictions from a model, from the dataloader.
- Parameters:
dl (DataLoader) – DataLoader object containing samples.
device (str, optional) – Device to run the model on. Defaults to ‘cpu’.
- Returns:
True labels, Predicted labels, Predicted probabilities of all samples in the dataloader.
shap_model
This file is an implementation of the custom SHAP model.