The NeuralNetwork Model#

In, 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 =

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


Adds a layer instance to the neural network model.


Configures the neural network model for training.


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


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


Loads the configuration of a neural network model from a JSON file generated by the function.


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


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


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(, 5))
>>> net.add(
>>> net.add(, 3))
>>> net.add(

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.