Hi, can I use the params data exported by mod.save_checkpoint within`mx.gluon.block.load_parameters`?

Hello everyone,

Now I have the parameter file exported using gluoncv.utils.export_block or mx.mod.save_checkpoint(), I wonder can I use this parameter file by mx.gluon.Block::load_parameters(params file) ?

Or, how should I change the format of my parameter file? I found that the parameter file obtained from save_checkpoint has a tuple containing two dicts: args and auxs. It seems the key-name from these args or auxs are different from names of parameter files obtained using mx.gluon.block.save_parameters().

Any advances? Thanks.

If you want to reload the model you can use the mx.gluon.HybridBlock.imports() function: see Load params from Symbol models to Gluon

If you just want to reload the parameters of your original model, the simplest is to rather do
net.save_parameters() and net.load_parameters(). There is backward compatibility in place so that you should potentially be able to do a net.load_parameters() on the exported parameters but in case of complex nested network and custom export function that might not work all the time. If you share your full code snippet we might be able to help you better.

Thanks for reply.

The static function actually is mx.gluon.SymbolBlock.imports() and that help me a lot.

I find that the SymbolBlock is inherited from HybridBlock, and I can use gluoncv.utils.export_block() to finish what I want to do. Thanks again.

1 Like