Here is how I save the parameters:
model_params_file = ‘bin_utilization.gluon.params’
bin_net.collect_params().save(model_params_file)
Here is how I load the parameters:
model_params_file = ‘bin_utilization.gluon.params’
bin_net2.collect_params().load(model_params_file, ctx=model_ctx)
Here is error message:
AssertionError Traceback (most recent call last)
in ()
1 model_params_file = ‘bin_utilization.gluon.params’
----> 2 bin_net2.collect_params().load(model_params_file, ctx=model_ctx)/home/ubuntu/anaconda3/envs/mxnet_p27/lib/python2.7/site-packages/mxnet/gluon/parameter.pyc in load(self, filename, ctx, allow_missing, ignore_extra, restore_prefix)
667 for name in self.keys():
668 assert name in arg_dict,
→ 669 “Parameter %s is missing in file %s”%(name[lprefix:], filename)
670 for name in arg_dict:
671 if name not in self._params:AssertionError: Parameter resnetv15_conv0_weight is missing in file bin_utilization.gluon.params
The networks are created using the same routine:
def build_net(hyper_params):
from mxnet.gluon.model_zoo import vision as modelsres_net = models.resnet152_v1(pretrained=True) new_net = gluon.nn.HybridSequential() 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() return new_net
One interesting fact:
Every time I tried it, the name of the parameter missing changes:
resnetv15_conv0_weight
from
resnetv11_conv0_weight
to
resnetv12_conv0_weight
all the way to
resnetv15_conv0_weight