PlainModel#

class PlainModel#

A plaintext representation of an ML model.

compare_weights(self: pyhelayers.PlainModel, plain: pyhelayers.PlainModel, verbose: bool, eps: float) None#

Compare weights of this PlainModel with the PlainModel pass as an argument. :param plain: The PlainModel object, :param verbose: bool, :param eps: double

static create(*args, **kwargs)#

Overloaded function.

  1. create(hyper_params: pyhelayers.PlainModelHyperParams) -> pyhelayers.PlainModel

    Creates and returns a plain model given hyperparameters.

    param hyper_params:

    The hyperparameters object.

  2. create(hyper_params: pyhelayers.PlainModelHyperParams, files: List[str]) -> pyhelayers.PlainModel

    Creates and returns a plain model given hyperparameters and names of files with contents to load.

    param hyper_params:

    The hyperparameters object.

    param files:

    List of file names with content to load, depending on the underlying model.

  3. create(hyper_params: pyhelayers.PlainModelHyperParams, buffers: List[bytes], files: List[str]) -> pyhelayers.PlainModel

    Creates and returns a plain model given hyperparameters, buffers with contents to load, and file names corresponding to each stream.

    param hyper_params:

    The hyperparameters object.

    param buffers:

    List of buffers with content to load, depending on the underlying model. All buffers must be rewindable.

    param files:

    List of file names corresponding to each buffer.

fit(self: pyhelayers.PlainModel, inputs: List[numpy.ndarray[numpy.float64]]) None#

Fit (train) the model.

Parameters:

inputs – The training inputs.

get_empty_he_model(self: pyhelayers.PlainModel, he_context: pyhelayers.HeContext) pyhelayers.HeModel#

Returns an empty (not initialized) HE model from the underlying type corresponding to this plain model.

Parameters:

he_context – The HE context.

get_hyper_params(self: pyhelayers.PlainModel) pyhelayers.PlainModelHyperParams#

Returns the model’s hyperparameters.

get_inputs_plain_tensor_metadata(self: pyhelayers.PlainModel) List[pyhelayers.PlainTensorMetadata]#

Returns a vector of PlainTensorMetadata objects. The i-th element of this vector contains metadata relating to the i-th input of this PlainModel (such as shape and batch dimension). If this PlainModel is initialized for prediction, the returned vector describes inputs for the the predict() method. If this PlainModel is initialized for fitting, the returned vector describes the inputs for the fit() method.

init(self: pyhelayers.PlainModel, hyper_params: pyhelayers.PlainModelHyperParams, buffers: List[bytes], files: List[str]) None#

Initializes a plain model given hyperparameters, buffers with contents to load, and file names corresponding to each stream.

Parameters:
  • hyper_params – The hyperparameters object.

  • buffers – List of buffers with content to load, depending on the underlying model. All buffers must be rewindable.

  • files – List of file names corresponding to each buffer.

init_from_files(self: pyhelayers.PlainModel, hyper_params: pyhelayers.PlainModelHyperParams, files: List[str]) None#

Initializes a plain model given hyperparameters and names of files with contents to load.

Parameters:
  • hyper_params – The hyperparameters object.

  • files – List of file names with content to load, depending on the underlying model.

is_fit_mode(self: pyhelayers.PlainModel) bool#

Returns indication for whether the initialized model is on fit-only or on predict-only mode.

is_verbose(self: pyhelayers.PlainModel) bool#

Returns indication for whether the initialized model verbosity is turned on or off.

predict(self: pyhelayers.PlainModel, inputs: List[numpy.ndarray[numpy.float64]]) List[numpy.ndarray[numpy.float64]]#

Run prediction (inference) over the model. Returns predictions.

Parameters:

inputs – The inputs.

validate_init(self: pyhelayers.PlainModel) None#

Validates this model has been initialized.