class documentation

class Sequential(BaseModel): (source)

Constructor: Sequential(**kwargs)

View In Hierarchy

A simple sequential model with multiple layers one after the other

This is the simplest model type that is commonly used. It has multiple layers in it sequentially connected by dense connected directed graph between neurons.

Method __init__ Initialize the required attributes.
Method add Method to add layers to the model
Method compile Method to initialize and compile the model
Method evaluate Method to evaluate the model with test data
Method fit Method to train the model and fit the data
Method predict Method to predict data labels
Method save Method to save the model to disk
Method summary Prints a summary of the model once compiled
Instance Variable callbacks A list of callback functions
Instance Variable epochs Number of epochs to train for
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 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 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

Inherited from BaseModel:

Method stop Method to stop the training
Instance Variable accuracy_val The accuracy value of the model at any instance
Instance Variable current_epoch The current epoch of the model during training
Instance Variable error_val The loss value of the model at any instance
Instance Variable is_fitting Is the model training right now
Instance Variable layers A list of layers in the model
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 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, loss: str, learning_rate: float = 0.001, verbose: bool = False, **kwargs): (source)

Method to initialize and compile the model

Initializes all the required values and performs required operations.

Args
loss:
The loss function to use. Available => mean_squared_error
learning_rate:
The learning_rate to use while fitting data
verbose:
Should progress be displayed in details
def evaluate(self, x_data: np.ndarray, y_data: np.ndarray, **kwargs): (source)

Method to evaluate the model with test data

Args
x_data:
The features of the dataset
y_data:
The label of the dataset
Keyword Args
is_validation: Whether the model is called during validation set checking step of training
def fit(self, train_x: np.ndarray, train_y: np.ndarray, epochs: int, **kwargs): (source)

Method to train the model and fit the data

It runs the training where the network does the learning.

Args
train_x:
The features of the dataset
train_y:
The label of the dataset
epochs:
The number of steps to run the training for
Keyword Args
validation_x: validation data set features validation_y: validation data set labels callbacks: A list of callback methods
def predict(self, input_x: np.ndarray) -> np.ndarray: (source)

Method to predict data labels

Args
input_x:
The features of the data to predict
Returns
The final output layer with the generated values
def save(self, save_path: str): (source)

Method to save the model to disk

Args
save_path:
Path to where the model will be saved, along with the name of the model file
def summary(self): (source)

Prints a summary of the model once compiled

callbacks = (source)

A list of callback functions

Number of epochs to train for

has_validation_data: bool = (source)

Boolean flag fo if the the model has validation data

is_compiled: bool = (source)

Has the model been compiled

learning_rate = (source)

The learning rate of the model

The loss function used by the model

loss_str = (source)

The name of the loss function used

train_data_x = (source)

The feature list of the dataset

train_data_y = (source)

The labels for each data in the dataset

validation_x = (source)

Features of validation set

validation_y = (source)

Labels of the validation set