ModelIoProcessor#

class ModelIoProcessor#

A class to handle the IO of an HE model, mainly, encoding and encrypting the inputs to be used for predict and fit, and decrypting and decoding the outputs of predict.

adjust_generic_packing_inputs_for_fit(self: pyhelayers.ModelIoProcessor, res: pyhelayers.EncryptedData, inputs: List[pyhelayers.CTileTensor]) None#

Adjusts generically-packed inputs to be used by the model for fit.

Parameters:
  • res – An output parameter to store the adjusted inputs in.

  • inputs – The given generically-packed inputs.

adjust_generic_packing_inputs_for_predict(self: pyhelayers.ModelIoProcessor, res: pyhelayers.EncryptedData, inputs: List[pyhelayers.CTileTensor]) None#

Adjusts generically-packed inputs to be used by the model for predict.

Parameters:
  • res – An output parameter to store the adjusted inputs in.

  • inputs – The given generically-packed inputs.

decrypt_decode_output(self: pyhelayers.ModelIoProcessor, output: pyhelayers.EncryptedData) numpy.ndarray[numpy.float64]#

Decrypts and decodes the output of predict, assuming a single output.

Parameters:

output – The single encrypted output of predict.

decrypt_decode_outputs(*args, **kwargs)#

Overloaded function.

  1. decrypt_decode_outputs(self: pyhelayers.ModelIoProcessor, outputs: pyhelayers.EncryptedData) -> List[numpy.ndarray[numpy.float64]]

    Decrypts and decodes the outputs of predict.

    param outputs:

    The encrypted outputs of predict.

  2. decrypt_decode_outputs(self: pyhelayers.ModelIoProcessor, outputs: pyhelayers.EncryptedBatch) -> List[numpy.ndarray[numpy.float64]]

    Decrypts and decodes the outputs of predict over a single batch.

    param outputs:

    The encrypted outputs of predict over a single batch.

encode_encrypt_inputs_for_fit(self: pyhelayers.ModelIoProcessor, res: pyhelayers.EncryptedData, inputs: List[numpy.ndarray[numpy.float64]]) None#

Encodes and encrypts the inputs for fit.

Parameters:
  • res – An output parameter to store the encrypted inputs in.

  • inputs – The plaintext inputs for fit.

encode_encrypt_inputs_for_predict(self: pyhelayers.ModelIoProcessor, res: pyhelayers.EncryptedData, inputs: List[numpy.ndarray[numpy.float64]]) None#

Encodes and encrypts the inputs for predict.

Parameters:
  • res – An output parameter to store the encrypted inputs in.

  • inputs – The plaintext inputs for predict.

get_data_packing(self: pyhelayers.ModelIoProcessor, num_elements: int | None = None) pyhelayers.DataPacking#

Returns the data packing required by the HE model for its inputs.

Parameters:

num_elements – The number of elements along the batch dimension, if applicable.