I would like to know if there is a way to resume training serialized Hybrid networks (saved as .JSON and .params file). Thanks a lot!
Hi MrDough,
yes, that should be possible.
If you constructed a net using Gluon and then saved it using the export
function, you can:
- construct the same net using Gluon and import its saved parameters using
net.load_parameters()
. - not construct the net using Gluon, but let MXNet construct it automatically from the JSON and .params file using
mx.mod.Module
. This is what I do when deploying a model in production.
You can find an example in tutorial [1]. If you have files mymodel-symbol.json
and mymodel-0012.params
, you can construct the network as follows:
sym, arg_params, aux_params = mx.model.load_checkpoint('mymodel', 12)
# Load the network into an MXNet module and bind the corresponding parameters
mod = mx.mod.Module(symbol=sym, context=mx.cpu())
mod.bind(for_training=False, data_shapes=[('data', (1,3,224,224))])
mod.set_params(arg_params, aux_params)
...
# Use the forward function for inference with a batch of data.
mod.forward(DataBatch(model_input))
regards,
Lieven
1 Like