NeuralNetwork.add#

usencrypt.ai.nn.NeuralNetwork.add(self, layer)#

Adds a layer instance to the neural network model.

Parameters

layer (usencrypt.ai.nn.layers.Layer) – The layer instance.

Raises

TypeError – If the layer is not of type usencrypt.ai.nn.layers.Layer.

Examples

Layers can be added to a usencrypt.ai.nn.NeuralNetwork model 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())
>>> net.summary()
Model: "NeuralNetwork"
=============================================================================
 Layer                    Type                Output Shape        Parameters
=============================================================================
 FCLayer                  FCLayer             (3, None)           15
 ReluLayer                ReluLayer           (3, None)           0
 FCLayer_1                FCLayer             (2, None)           8
 SoftmaxLayer             SoftmaxLayer        (2, None)           0
=============================================================================
 Total Parameters: 23
 Trainable Parameters: 23
 Non-Trainable Parameters: 0
=============================================================================