MyCaffe  1.12.2.41
Deep learning software for Windows C# programmers.
MyCaffe.converter.onnx.MyCaffeConversionControl< T > Class Template Reference

The MyCaffeConversionControl handles converting between MyCaffe and ONNX formats. The OnnxControl is used to read and write ONNX files. More...

Inheritance diagram for MyCaffe.converter.onnx.MyCaffeConversionControl< T >:
System.ComponentModel.Component

Public Member Functions

 MyCaffeConversionControl ()
 The constructor. More...
 
 MyCaffeConversionControl (IContainer container)
 The constructor. More...
 
void SetWeightScaling (double dfMin, double dfMax)
 Set the scaling factors applied to the weights. More...
 
void ConvertMyCaffeToOnnxFile (CudaDnn< T > cuda, Log log, MyCaffeModelData data, string strOutputFile, int nOpSetVersion=9, bool bUseRawData=true, OnnxDefinitions.DataType dstDataType=OnnxDefinitions.DataType.FLOAT)
 Convert a MyCaffe model description, weights and optionally mean image from the MyCaffe model format to the ONNX format and save the result as a .onnx model file. More...
 
ModelProto ConvertMyCaffeToOnnx (CudaDnn< T > cuda, Log log, MyCaffeModelData data, int nOpSetVersion=9, bool bUseRawData=true, OnnxDefinitions.DataType dstDataType=OnnxDefinitions.DataType.FLOAT)
 Convert a MyCaffe model description, weights and optionally mean image from the MyCaffe model format to the ONNX format and return the ONNX ModelProto object containing the model in the ONNX format. More...
 
ModelProto ConvertMyCaffeToOnnx (MyCaffeControl< T > ctrl, int nOpSetVersion=9, bool bUseRawData=true, OnnxDefinitions.DataType dstDataType=OnnxDefinitions.DataType.FLOAT, Phase phase=Phase.RUN)
 Convert a model currently loaded into the MyCaffeControl to an ONNX ModelProto. More...
 
void ConvertMyCaffeToOnnxFile (MyCaffeControl< T > ctrl, string strOnnxFile, int nOpSetVersion=9, bool bUseRawData=true, OnnxDefinitions.DataType dstDataType=OnnxDefinitions.DataType.FLOAT, Phase phase=Phase.RUN)
 Convert a model currently loaded into the MyCaffeControl to an ONNX .onnx model file. More...
 
MyCaffeModelData ConvertOnnxToMyCaffeFromFile (CudaDnn< T > cuda, Log log, string strOnnxFile, bool bFixlupNeuronNodes=true, bool bIncludeLastLayerWeights=false, DatasetDescriptor dsTraining=null)
 Convert an ONNX .onnx model file to the MyCaffe model description, weights and optionally mean image. More...
 
MyCaffeModelData ConvertOnnxToMyCaffe (CudaDnn< T > cuda, Log log, ModelProto onnxModel, bool bFixupNeuronNodes=true, bool bIncludeLastLayerWeights=false, DatasetDescriptor dsTraining=null)
 Convert an ONNX ModelProto to the MyCaffe model description, weights and optionally mean image. More...
 
- Public Member Functions inherited from System.ComponentModel.Component
 Component ()
 

Static Public Member Functions

static float[] getDataAsFloat (TensorProto tensor)
 Converts the tensor data into an array of float. More...
 
static double[] getDataAsDouble (TensorProto tensor)
 Converts the tensor data into an array of double. More...
 

Properties

List< string > IgnoreLayerNames [getset]
 Get/set the list of layer names to ignore (layers are ignored when they contain the text from one of these items). More...
 
string ReportString [get]
 Returns the report from the conversion. More...
 

Detailed Description

The MyCaffeConversionControl handles converting between MyCaffe and ONNX formats. The OnnxControl is used to read and write ONNX files.

Template Parameters
TSpecifies the base type used by MyCaffe which is either float or double.

Definition at line 35 of file MyCaffeConversionControl.cs.

Constructor & Destructor Documentation

◆ MyCaffeConversionControl() [1/2]

◆ MyCaffeConversionControl() [2/2]

The constructor.

Parameters
containerA container holding the component.

Definition at line 62 of file MyCaffeConversionControl.cs.

Member Function Documentation

◆ ConvertMyCaffeToOnnx() [1/2]

ModelProto MyCaffe.converter.onnx.MyCaffeConversionControl< T >.ConvertMyCaffeToOnnx ( CudaDnn< T >  cuda,
Log  log,
MyCaffeModelData  data,
int  nOpSetVersion = 9,
bool  bUseRawData = true,
OnnxDefinitions.DataType  dstDataType = OnnxDefinitions.DataType.FLOAT 
)

Convert a MyCaffe model description, weights and optionally mean image from the MyCaffe model format to the ONNX format and return the ONNX ModelProto object containing the model in the ONNX format.

Parameters
cudaSpecifies the connection to cuda uses to interact with the GPU.
logSpecifies the output log used to show progress.
dataSpecifies the MyCaffe model data including the model description, the weights and optionally, the image mean.
nOpSetVersionSpecifies the Operation set version (default = 9).
bUseRawDataOptionally, specifies whether or not to store tensor data as RawData or as the native FloatData or DoubleData (default = true).
dstDataTypeOptionally, specifies the output data type, which currently can be either FLOAT or DOUBLE (default = FLOAT).
Returns
The model is returned in the ONNX format as a ModelProto (defined within the OnnxControl)

Definition at line 141 of file MyCaffeConversionControl.cs.

◆ ConvertMyCaffeToOnnx() [2/2]

ModelProto MyCaffe.converter.onnx.MyCaffeConversionControl< T >.ConvertMyCaffeToOnnx ( MyCaffeControl< T >  ctrl,
int  nOpSetVersion = 9,
bool  bUseRawData = true,
OnnxDefinitions.DataType  dstDataType = OnnxDefinitions.DataType.FLOAT,
Phase  phase = Phase.RUN 
)

Convert a model currently loaded into the MyCaffeControl to an ONNX ModelProto.

Parameters
ctrlSpecifies the MyCaffeControl object.
nOpSetVersionSpecifies the Operation set version (default = 9).
bUseRawDataOptionally, specifies whether or not to store tensor data as RawData or as the native FloatData or DoubleData (default = true).
dstDataTypeOptionally, specifies the output data type, which currently can be either FLOAT or DOUBLE (default = FLOAT).
phaseOptionally, specifies the phase (which netork) to convert (default = RUN).
Returns
The ONNX model proto is returns that matches the network converted.

Definition at line 175 of file MyCaffeConversionControl.cs.

◆ ConvertMyCaffeToOnnxFile() [1/2]

void MyCaffe.converter.onnx.MyCaffeConversionControl< T >.ConvertMyCaffeToOnnxFile ( CudaDnn< T >  cuda,
Log  log,
MyCaffeModelData  data,
string  strOutputFile,
int  nOpSetVersion = 9,
bool  bUseRawData = true,
OnnxDefinitions.DataType  dstDataType = OnnxDefinitions.DataType.FLOAT 
)

Convert a MyCaffe model description, weights and optionally mean image from the MyCaffe model format to the ONNX format and save the result as a .onnx model file.

Parameters
cudaSpecifies the connection to cuda uses to interact with the GPU.
logSpecifies the output log used to show progress.
dataSpecifies the MyCaffe model data including the model description, the weights and optionally, the image mean.
strOutputFileSpecifies the .onnx output file.
nOpSetVersionSpecifies the Operation set version (default = 9).
bUseRawDataOptionally, specifies whether or not to store tensor data as RawData or as the native FloatData or DoubleData (default = true).
dstDataTypeOptionally, specifies the output data type, which currently can be either FLOAT or DOUBLE (default = FLOAT).

Definition at line 120 of file MyCaffeConversionControl.cs.

◆ ConvertMyCaffeToOnnxFile() [2/2]

void MyCaffe.converter.onnx.MyCaffeConversionControl< T >.ConvertMyCaffeToOnnxFile ( MyCaffeControl< T >  ctrl,
string  strOnnxFile,
int  nOpSetVersion = 9,
bool  bUseRawData = true,
OnnxDefinitions.DataType  dstDataType = OnnxDefinitions.DataType.FLOAT,
Phase  phase = Phase.RUN 
)

Convert a model currently loaded into the MyCaffeControl to an ONNX .onnx model file.

Parameters
ctrlSpecifies the MyCaffeControl object.
strOnnxFileSpecifies the output .onnx file.
nOpSetVersionSpecifies the Operation set version (default = 9).
bUseRawDataOptionally, specifies whether or not to store tensor data as RawData or as the native FloatData or DoubleData (default = true).
dstDataTypeOptionally, specifies the output data type, which currently can be either FLOAT or DOUBLE (default = FLOAT).
phaseOptionally, specifies the phase (which netork) to convert (default = RUN).

Definition at line 190 of file MyCaffeConversionControl.cs.

◆ ConvertOnnxToMyCaffe()

MyCaffeModelData MyCaffe.converter.onnx.MyCaffeConversionControl< T >.ConvertOnnxToMyCaffe ( CudaDnn< T >  cuda,
Log  log,
ModelProto  onnxModel,
bool  bFixupNeuronNodes = true,
bool  bIncludeLastLayerWeights = false,
DatasetDescriptor  dsTraining = null 
)

Convert an ONNX ModelProto to the MyCaffe model description, weights and optionally mean image.

Parameters
cudaSpecifies the connection to cuda uses to interact with the GPU.
logSpecifies the output log used to show progress.
onnxModelSpecifies the ONNX model.
bFixupNeuronNodesOptionally, specifies to fixup the neuron nodes (e.g. Relu, Prelu, Elu, Sigmoid, Tahn, etc.) by connecting them to inline nodes by connnecting them back to their parent which is common in Caffe type models (default = true).
bIncludeLastLayerWeightsOptionally, specifies to include the weights for the last layer (default = false, usually not included for transfer learning).
dsTrainingOptionally, specifies a training dataset which when supplied converts the model to a training model where inputs are replaced with data layers, and outputs (e.g. softmax) with loss and accuracy layers (default = false).
Returns
The MyCaffe model description, model weights and image mean are returned as a MyCaffeModelData object.

Definition at line 231 of file MyCaffeConversionControl.cs.

◆ ConvertOnnxToMyCaffeFromFile()

MyCaffeModelData MyCaffe.converter.onnx.MyCaffeConversionControl< T >.ConvertOnnxToMyCaffeFromFile ( CudaDnn< T >  cuda,
Log  log,
string  strOnnxFile,
bool  bFixlupNeuronNodes = true,
bool  bIncludeLastLayerWeights = false,
DatasetDescriptor  dsTraining = null 
)

Convert an ONNX .onnx model file to the MyCaffe model description, weights and optionally mean image.

Parameters
cudaSpecifies the connection to cuda uses to interact with the GPU.
logSpecifies the output log used to show progress.
strOnnxFileSpecifies the ONNX .onnx file.
bFixlupNeuronNodesOptionally, specifies to fixup the neuron nodes (e.g. Relu, Prelu, Elu, Sigmoid, Tahn, etc.) by connecting them to inline nodes by connnecting them back to their parent which is common in Caffe type models (default = true).
bIncludeLastLayerWeightsOptionally, specifies to include the weights for the last layer (default = false, usually not included for transfer learning).
dsTrainingOptionally, specifies a training dataset which when supplied converts the model to a training model where inputs are replaced with data layers, and outputs (e.g. softmax) with loss and accuracy layers (default = false).
Returns
The MyCaffe model description, model weights and image mean are returned as a MyCaffeModelData object.

Definition at line 209 of file MyCaffeConversionControl.cs.

◆ getDataAsDouble()

static double[] MyCaffe.converter.onnx.MyCaffeConversionControl< T >.getDataAsDouble ( TensorProto  tensor)
static

Converts the tensor data into an array of double.

Parameters
tensorSpecifies the tensor to convert.
Returns
An array of double values is returned.

Definition at line 1793 of file MyCaffeConversionControl.cs.

◆ getDataAsFloat()

static float[] MyCaffe.converter.onnx.MyCaffeConversionControl< T >.getDataAsFloat ( TensorProto  tensor)
static

Converts the tensor data into an array of float.

Parameters
tensorSpecifies the tensor to convert.
Returns
An array of float values is returned.

Definition at line 1694 of file MyCaffeConversionControl.cs.

◆ SetWeightScaling()

void MyCaffe.converter.onnx.MyCaffeConversionControl< T >.SetWeightScaling ( double  dfMin,
double  dfMax 
)

Set the scaling factors applied to the weights.

Parameters
dfMinSpecifies the minimum of the range.
dfMaxSpecifies the maximum of the range.

Definition at line 86 of file MyCaffeConversionControl.cs.

Property Documentation

◆ IgnoreLayerNames

List<string> MyCaffe.converter.onnx.MyCaffeConversionControl< T >.IgnoreLayerNames
getset

Get/set the list of layer names to ignore (layers are ignored when they contain the text from one of these items).

Definition at line 95 of file MyCaffeConversionControl.cs.

◆ ReportString

Returns the report from the conversion.

Definition at line 104 of file MyCaffeConversionControl.cs.


The documentation for this class was generated from the following file: