mirror of
https://github.com/luxfhe/ml-sdk.git
synced 2026-10-30 18:13:04 +00:00
Machine Learning with FHE - fork of Zama Concrete-ML - Built-in FHE-friendly ML models - scikit-learn compatible API - PyTorch model conversion - Quantization-aware training
3.3 KiB
3.3 KiB
module concrete.ml.torch.numpy_module
A torch to numpy module.
Global Variables
- OPSET_VERSION_FOR_ONNX_EXPORT
class NumpyModule
General interface to transform a torch.nn.Module to numpy module.
Args:
torch_model(Union[nn.Module, onnx.ModelProto]): A fully trained, torch model along with its parameters or the onnx graph of the model.dummy_input(Union[torch.Tensor, Tuple[torch.Tensor, ...]]): Sample tensors for all the module inputs, used in the ONNX export to get a simple to manipulate nn representation.debug_onnx_output_file_path: (Optional[Union[Path, str]], optional): An optional path to indicate where to save the ONNX file exported by torch for debug. Defaults to None.
method __init__
__init__(
model: Union[Module, ModelProto],
dummy_input: Optional[Tensor, Tuple[Tensor, ]] = None,
debug_onnx_output_file_path: Optional[Path, str] = None
)
property onnx_model
Get the ONNX model.
.. # noqa: DAR201
Returns:
_onnx_model(onnx.ModelProto): the ONNX model
property onnx_preprocessing
Get the ONNX preprocessing.
.. # noqa: DAR201
Returns:
_onnx_preprocessing(onnx.ModelProto): the ONNX preprocessing
method forward
forward(*args: ndarray) → Union[ndarray, Tuple[ndarray, ]]
Apply a forward pass on args with the equivalent numpy function only.
Args:
*args: the inputs of the forward function
Returns:
Union[numpy.ndarray, Tuple[numpy.ndarray, ...]]: result of the forward on the given inputs
method pre_processing
pre_processing(*args: ndarray) → Tuple[ndarray, ]
Apply a preprocessing pass on args with the equivalent numpy function only.
Args:
*args: the inputs of the preprocessing function
Returns:
Union[numpy.ndarray, Tuple[numpy.ndarray, ...]]: result of the preprocessing on the given inputs or the original inputs if no preprocessing function is defined