Cross post here
Problem remains in Mathematica 11.2
First defining the net
SeedRandom[1234];
net = NetInitialize@NetChain[{5, 3}, "Input" -> 2];
{net[{1, 2}], net[{0, 0}], net[{0.1, 0.3}]}
{{1.27735, -1.21455, -1.02647}, {0., 0.,
0.}, {0.141054, -0.145882, -0.099945}}
Exporting it to net of MXNet.
Export["simple model-symbol.json", net, "MXNet"]
The JSON file(It define the net structure) is
Via the code we can see the name of parameter is the same between params and JSON file.
import mxnet as mx
mx.nd.load('simple model-0000.params')
It has error ValueError: need more than 1 value to unpack when importing the net.
import mxnet as mx
sym, arg_params, aux_params = mx.model.load_checkpoint('simple model', 0)
Complete code to make prediction.(data_names and label_names can be shown in JSON file.)
import mxnet as mx
import numpy as np
sym, arg_params, aux_params = mx.model.load_checkpoint('simple model', 0)
mod = mx.mod.Module(symbol=sym,data_names=['Input'],label_names=['2'])
mod.bind(for_training=False, data_shapes=[('Input', (1,2))])
mod.set_params(arg_params, aux_params)
input_data=np.array([[1,2]])
array = mx.nd.array(input_data)
from collections import namedtuple
Batch = namedtuple('Batch', ['Input'])
mod.forward(Batch([array]))
prob = mod.get_outputs()[0].asnumpy()
prob = np.squeeze(prob)
print prob
Version:
Mathematica "11.2.0 for Microsoft Windows (64-bit) (September 11, 2017)"
MXNet 0.11.1 (the latest version 20170905_mxnet_x64_vc14_cpu.7z)
How to fix it?





