The weight optimizer that will be used to tune the weights in order of minimizing
the loss.
loss: class
Loss function used to measure the model’s performance. SquareLoss or CrossEntropy.
validation: tuple
A tuple containing validation data and labels (X, y)
“”"
def init(self, optimizer, loss, validation_data=None):
self.optimizer = optimizer
self.layers = []
self.errors = {“training”: [], “validation”: []}
self.loss_function = loss()
self.progressbar = progressbar.ProgressBar(widgets=bar_widgets)
self.val_set = None
if validation_data:
X, y = validation_data
self.val_set = {“X”: X, “y”: y}
def set_trainable(self, trainable):
“”" Method which enables freezing of the weights of the network’s layers. “”"
for layer in self.layers:
layer.trainable = trainable