NeuralNetwork.fit#

usencrypt.ai.nn.NeuralNetwork.fit(self, X_train, y_train, batch_size=32, epochs=1, metrics=None, save_file_path=None)#

Trains the neural network model for a fixed number of epochs. Computation in batches is supported.

This function assumes the training data X_train is of shape (m, n), where m is the number of training examples and n is the number of features. Further, it also assumes the training labels y_train are represented by a one-hot encoded matrix of shape (m, c), where c is the number of classes.

Parameters
  • X_train (list or numpy.ndarray) – The input data.

  • y_train (list or numpy.ndarray) – The target labels.

  • batch_size (int) – The number of samples used per gradient update. Defaults to 32.

  • epochs (int) – The number of epochs to train the model. Defaults to 1.

  • metrics ({'accuracy'}) – A list of performance metrics to be used for training. If None, only the training loss is used. Defaults to None.

  • save_file_path (str) – Path for the resulting history file. Defaults to None.

Returns

The history dictionary containing each updated performance metric per epoch.

Return type

dict

Raises

TypeError – If the metrics parameter is not a list or numpy.ndarray.

Examples

For examples on how to work with the neural network model, please refer to our corresponding tutorials.