Conversion
pyNeVer provides conversion capabilities to import a NN model in the ONNX and pyTorch file formats, as well as to export to these formats trained NNs.
Representation
- class pynever.strategies.conversion.representation.AlternativeRepresentation(path, identifier=None)[source]
Bases:
ABCAn abstract class used to represent an alternative representation for a neural network.
- class pynever.strategies.conversion.representation.ONNXNetwork[source]
Bases:
AlternativeRepresentationA class used to represent a ONNX representation for a neural network.
- class pynever.strategies.conversion.representation.PyTorchNetwork[source]
Bases:
AlternativeRepresentationA class used to represent a PyTorch representation for a neural network.
- class pynever.strategies.conversion.representation.ConversionStrategy[source]
Bases:
ABCAn abstract class used to represent a Conversion Strategy.
- abstractmethod from_neural_network(network)[source]
Convert the neural network of interest to an alternative representation determined in the concrete children.
- Parameters:
network (NeuralNetwork) – The neural network to convert.
- Returns:
The alternative representation resulting from the conversion of the original network.
- Return type:
- abstractmethod to_neural_network(alt_rep)[source]
Convert the alternative representation of interest to the internal one.
- Parameters:
alt_rep (AlternativeRepresentation) – The Alternative Representation to convert.
- Returns:
The Neural Network resulting from the conversion of Alternative Representation.
- Return type:
- pynever.strategies.conversion.representation.load_network_path(path)[source]
Method to load a network from a path in an Alternative Representation.
- Parameters:
path (str) – Path to the network.
- Returns:
The AlternativeRepresentation object if the network is supported, None otherwise.
- Return type:
Optional[AlternativeRepresentation]
Converters
- class pynever.strategies.conversion.converters.onnx.ONNXConverter[source]
Bases:
ConversionStrategyA class used to represent the conversion strategy for ONNX models.
- from_neural_network(network)[source]
Convert the neural network of interest to a ONNX representation.
- Parameters:
network (NeuralNetwork) – The neural network to convert.
- Returns:
The ONNX representation resulting from the conversion of the original network.
- Return type:
- to_neural_network(alt_rep)[source]
Convert the ONNX representation of interest to the internal one.
- Parameters:
alt_rep (ONNXNetwork) – The ONNX Representation to convert.
- Returns:
The Neural Network resulting from the conversion of ONNX Representation.
- Return type:
- class pynever.strategies.conversion.converters.pytorch.PyTorchConverter[source]
Bases:
ConversionStrategyA class used to represent the conversion strategy for PyTorch models.
- from_neural_network(network)[source]
Convert the neural network of interest to a PyTorch representation.
- Parameters:
network (NeuralNetwork) – The neural network to convert.
- Returns:
The PyTorch representation resulting from the conversion of the original network.
- Return type:
- to_neural_network(alt_rep)[source]
Convert the PyTorch representation of interest to the internal one.
- Parameters:
alt_rep (PyTorchNetwork) – The PyTorch Representation to convert.
- Returns:
The Neural Network resulting from the conversion of PyTorch Representation.
- Return type: