ConvNetSharp icon indicating copy to clipboard operation
ConvNetSharp copied to clipboard

Import ONNX models / models from other frameworks

Open idow09 opened this issue 4 years ago • 2 comments

What is the best way to import a model into ConvNetSharp, assuming all the relevant layers exist? Are there any plans on supporting such conversions in the future? Is it possible to do so "manually" somehow? My models are trained using PyTorch, so I can export them to ONNX format if needed. Thanks for your work

idow09 avatar Mar 22 '20 15:03 idow09

It would be great to load ONNX file. So far this is not implemented. I'm not very familiar with ONNX but I understand data is represented as a computation graph.

So it would go like this:

  1. Read ONNX file / computation graph (protobuf)
  2. Create computation graph using ConvNetSharp.Flow

There are only a few ops (computation graph nodes) implemented but that could be enough to run simple models. I think this is completely feasible :)

cbovar avatar Mar 23 '20 03:03 cbovar

I gave it a try: You can take a look at the branch Onnx This class implements basic onnx loading (Conv / Relu and MaxPool ops).

But some more ops such as Gemm , Gather, Concat, Unsqueeze, Reshape, Constant, Shape, are needed, even for a simple model such as model.py: image Some of those ops already exist here, others have to be implement (e.g. Gemm).

cbovar avatar Mar 24 '20 04:03 cbovar