Skip to main content

machine learning - How to export an MXNet?


I was hoping there was some way to generate the .params and .json file needed to define an MXNet model, from a network trained using NetTrain[] in Mathematica. I was hopeful because I found these functions in the NeuralNetworks` package:


NeuralNetworks`ToMXNetSymbol
NeuralNetworks`ToMXNetJSON

You can use them on a net link this:


<< NeuralNetworks`;

net = NetInitialize@NetChain[{
ConvolutionLayer[20, {5, 5}],
ElementwiseLayer[Ramp],
PoolingLayer[{2, 2}, {2, 2}],
FlattenLayer[],
DotPlusLayer[500],
ElementwiseLayer[Ramp]
}, "Input" -> NetEncoder[{"Image", {32, 32}}]];
ImportString[Normal@NeuralNetworks`ToMXNetJSON[net][[1]], "RawJSON"]
NeuralNetworks`ToMXNetSymbol[net]


Now, ToMXNetJSON[] returns a tuple, and it looks like the first element is the JSON for the symbol file. But I don't know what the second element is, and I don't have a clue as to what ToMXNetSymbol[] is returning.


Motivation: A solution to this would enable one to take any net from MMA and run it in C or Python with GPU inference!




Comments