I am getting the following error message:
Traceback (most recent call last):
File “train_gluon.py”, line 173, in
bin_net.save_params(model_params_file)
File “/home/ubuntu/anaconda3/envs/mxnet_p27/lib/python2.7/site-packages/mxnet/gluon/block.py”, line 300, in save_params
self.collect_params().save(filename, strip_prefix=self.prefix)
File “/home/ubuntu/anaconda3/envs/mxnet_p27/lib/python2.7/site-packages/mxnet/gluon/parameter.py”, line 637, in save
strip_prefix, param.name, strip_prefix))
ValueError: Prefix hybridsequential0_ is to be striped before saving, but Parameter resnetv10_conv0_weight does not start with hybridsequential0_. If you are using Block.save_params, This may be due to your Block shares parameters from other Blocks or you forgot to use with name_scope()
during init. Consider switching to Block.collect_params.save and Block.collect_params.load instead.
But I do use name_scope with init:
with new_net.name_scope():
pretrained_features = res_net.features
new_tail = gluon.nn.HybridSequential()
new_tail.add(
gluon.nn.Dense(hyper_params.NUM_HIDDENS1, activation=hyper_params.ACTIVATION),
gluon.nn.Dropout(hyper_params.DROPOUT),
gluon.nn.Dense(hyper_params.NUM_HIDDENS2, activation=hyper_params.ACTIVATION),
gluon.nn.Dropout(hyper_params.DROPOUT),
gluon.nn.Dense(hyper_params.NUM_OUTPUTS)
)
new_tail.initialize(mx.init.Xavier(magnitude=hyper_params.MAGNITUDE))
new_net.add(
pretrained_features,
new_tail
)
new_net.hybridize()