PlainModel#

class PlainModel#

A plaintext representation of an ML model.

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_input_shapes_for_fit(self: pyhelayers.PlainModel) List[List[int]]#

Returns the expected shapes of the inputs for fit. If batch dimension is applicable, the value of the batch dimension is set to zero.

get_input_shapes_for_predict(self: pyhelayers.PlainModel) List[List[int]]#

Returns the expected shapes of the inputs for predict. If batch dimension is applicable, the value of the batch dimension is set to zero.

get_inputs_names_for_fit(self: pyhelayers.PlainModel) List[str]#

Returns the names of inputs the model expects for fit, to be used to deduce the order in which multiple inputs are expected.

get_inputs_names_for_predict(self: pyhelayers.PlainModel) List[str]#

Returns the names of inputs the model expects for predict, to be used to deduce the order in which multiple inputs are expected.

get_outputs_names_of_predict(self: pyhelayers.PlainModel) List[str]#

Returns the names of outputs the model returns after predict, to be used to deduce the order in which multiple outputs are returned.

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.