The NeuralNetwork Model#

In USEncrypt.ai, the NeuralNetwork model allows users to define, train, evaluate, store, and load neural networks using encrypted data. A NeuralNetwork object is defined as follows:

>>> net = usencrypt.ai.nn.NeuralNetwork()

From here, the NeuralNetwork API gives access to the following member functions:

add

Adds a layer instance to the neural network model.

compile

Configures the neural network model for training.

evaluate

Evaluates the neural network model with the given test set, returning the loss and performance metric results.

fit

Trains the neural network model for a fixed number of epochs.

load_model

Loads the configuration of a neural network model from a JSON file generated by the usencrypt.ai.nn.NeuralNetwork.save_model() function.

predict

Uses the neural network model to generate predictions based on an input of samples.

save_model

Saves the neural network model into a JSON file for future use.

summary

Prints a summary of the neural network architecture.

Creating a NeuralNetwork Model#

Once an instance of NeuralNetwork is created, its architecture can be defined using the add() function:

>>> net.add(usencrypt.ai.nn.layers.FCLayer(4, 5))
>>> net.add(usencrypt.ai.nn.layers.ReluLayer())
>>> net.add(usencrypt.ai.nn.layers.FCLayer(5, 3))
>>> net.add(usencrypt.ai.nn.layers.SoftmaxLayer())

Once a model is defined, using the summary() function gives an overview of its architecture:

>>> net.summary()
Model: "NeuralNetwork"
=============================================================================
 Layer                    Type                Output Shape        Parameters
=============================================================================
 FCLayer                  FCLayer             (5, None)           25
 ReluLayer                ReluLayer           (5, None)           0
 FCLayer_1                FCLayer             (3, None)           18
 SoftmaxLayer             SoftmaxLayer        (3, None)           0
=============================================================================
 Total Parameters: 43
 Trainable Parameters: 43
 Non-Trainable Parameters: 0
=============================================================================

Next Steps#

From here, the defined neural network can be trained using encrypted data. See Training and Evaluating a NeuralNetwork Model.