MLToolbox#

MLToolbox provides tools for converting CNN models into polynomial representations while minimizing performance degradation. The MLToolbox tutorial explores the process of making models FHE-friendly and demonstrates how MLToolbox simplifies this task. The resulting models can then be used for secure inference over HE.

Check out the following notebook for a usage example: MLToolbox Notebook.

The polynomial adaptation process is based on the method presented in this paper. In general, it consists of three steps:

  1. Loading a pretrained non-polynomial model.

  2. Range minimization: fine-tuning the model while adding a range-loss term to minimize the input to the non-polynomial layers.

  3. Polynomial approximation: Replacing non-polynomial activation layers with polynomial approximations and fine-tuning until convergence.

Resources#

Classes#

arguments.Arguments(model, dataset_name, ...)

This class defines the user arguments object, and sets the default values for some parameters

poly_activation_converter.PolyActivationConverter(...)

This class helps in the FHE conversion of the model; namely the activation replacement.

poly_activation_converter.Trainer(args[, ...])

This class represents a training object, that has all the needed components for a training, like dataLoaders, optimizer, model etc.