class documentation

class BaseModel: (source)

Known subclasses: shamboflow.models.Sequential

Constructor: BaseModel(**kwargs)

View In Hierarchy

The Base class for models

All other models need to inherit from this class. It provides a template with all the methods a model will need to execute.

Attributes
layers:
A list of layers present in the model in the order from input to output
weights:
A list of all weight matrices for the layers in the model
loss:
The loss/cost function to use calculate error of the model at a given state
train_data_x:
The training data or features
train_data_y:
Training features' corresponding labels

And more attributes

Method __init__ Initialize the required attributes.
Method add Method to add layers to the model
Method compile Model compilation method
Method evaluate Evaluates metrics based on a Test dataset
Method fit Method to train the model on data
Method predict Calculate inference using the trained model
Method save Saves the model to the disk
Method stop Method to stop the training
Method summary Prints a summary of the model with all necessary details
Instance Variable accuracy_val The accuracy value of the model at any instance
Instance Variable callbacks A list of callback functions
Instance Variable current_epoch The current epoch of the model during training
Instance Variable epochs Number of epochs to train for
Instance Variable error_val The loss value of the model at any instance
Instance Variable has_validation_data Boolean flag fo if the the model has validation data
Instance Variable is_compiled Has the model been compiled
Instance Variable is_fitting Is the model training right now
Instance Variable layers A list of layers in the model
Instance Variable learning_rate The learning rate of the model
Instance Variable loss The loss function used by the model
Instance Variable loss_str The name of the loss function used
Instance Variable metrics A dictionary of metrics for the model. Includes loss, acc, val_loss, val_acc
Instance Variable parameters Amount of trainable parameters in the model
Instance Variable test_data_x Features of the test dataset
Instance Variable test_data_y Labels for the test dataset
Instance Variable train_data_x The feature list of the dataset
Instance Variable train_data_y The labels for each data in the dataset
Instance Variable validation_x Features of validation set
Instance Variable validation_y Labels of the validation set
Instance Variable weights A list of all weights between each layers
def __init__(self, **kwargs): (source)

Initialize the required attributes.

Also optionally takes in a list of layers as a parameter.

Keyword Args
layers: It takes a list of layers and them to the model
def add(self, layer: BaseLayer): (source)

Method to add layers to the model

Args
layer:
layer to add to the model
def compile(self): (source)

Model compilation method

To be implemented in child

def evaluate(self): (source)

Evaluates metrics based on a Test dataset

def fit(self): (source)

Method to train the model on data

To be implemented in child

def predict(self): (source)

Calculate inference using the trained model

def save(self): (source)

Saves the model to the disk

def stop(self): (source)

Method to stop the training

def summary(self): (source)

Prints a summary of the model with all necessary details

accuracy_val: float = (source)

The accuracy value of the model at any instance

callbacks: list = (source)

A list of callback functions

current_epoch: int = (source)

The current epoch of the model during training

Number of epochs to train for

error_val: float = (source)

The loss value of the model at any instance

has_validation_data: bool = (source)

Boolean flag fo if the the model has validation data

is_compiled: bool = (source)

Has the model been compiled

is_fitting: bool = (source)

Is the model training right now

A list of layers in the model

learning_rate: float = (source)

The learning rate of the model

The loss function used by the model

loss_str: str = (source)

The name of the loss function used

A dictionary of metrics for the model. Includes loss, acc, val_loss, val_acc

parameters: int = (source)

Amount of trainable parameters in the model

test_data_x: np.ndarray = (source)

Features of the test dataset

test_data_y: np.ndarray = (source)

Labels for the test dataset

train_data_x: np.ndarray = (source)

The feature list of the dataset

train_data_y: np.ndarray = (source)

The labels for each data in the dataset

validation_x: np.ndarray = (source)

Features of validation set

validation_y: np.ndarray = (source)

Labels of the validation set

weights: list[np.ndarray] = (source)

A list of all weights between each layers