NeuralNetwork.compile#

usencrypt.ai.nn.NeuralNetwork.compile(self, loss, optimizer)#

Configures the neural network model for training.

Parameters
Raises
Examples

A given loss function and optimizer can be compiled into a usencrypt.ai.nn.NeuralNetwork object as follows:

>>> import usencrypt as ue
>>> net = ue.ai.nn.NeuralNetwork()
>>> net.add(ue.ai.nn.layers.FCLayer(4, 3))
>>> net.add(ue.ai.nn.layers.ReluLayer())
>>> net.add(ue.ai.nn.layers.FCLayer(3, 2))
>>> net.add(ue.ai.nn.layers.SoftmaxLayer())
>>> loss = ue.ai.losses.BinaryCrossEntropy()
>>> optimizer = ue.ai.optimizers.SGD(learning_rate=0.01, momentum=0.9)
>>> net.compile(loss, optimizer)