Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

General structure of onnx export after training would look something like this:

data_iter = data_process(mnist)
sym = construct_model_def(...)
# create module for training
mod = mx.mod.Module(symbol=sym, ...)
# train model
mod.fit(data_iter, optimizer='...', optimizer_params='...', ...)
# get parameters of trained model
params = mod.get_params()

# save into different format using sym/params
mx.serde.export(sym, params, format=‘onnx’, filename=”model.onnx”)

# OR save into different format using module directly

mx.serde.export(mod, format=‘onnx’, filename=”model.onnx”)

General structure of onnx import would look something like this:

# Import model
sym, params = mxnet.serde.import(input_file, in_format=‘onnx’)

# create module for inference
mod = mx.mod.Module(symbol=sym, data_names=..., context=mx.cpu(), label_names=None)
mod.bind(for_training=False, data_shapes=..., label_shapes=None)

# set parameters
mod.set_params(arg_params=params, aux_params=None, allow_missing=True)

# forward on the provided data batch
mod.forward(Batch([data_batch]))

 

Testing

Integrate MXNet's import/export(backend/frontend) functionality with onnx test infrastructure. It has both the combination of unit tests per operator and model level tests. It'd make our testing procedure easier. Refer test backend added for onnx-mxnet package.

...