haojin2 opened a new issue #19257:
URL: https://github.com/apache/incubator-mxnet/issues/19257
## Desciption
Gluon will throw exception when trying to load back model weights that were
just saved seconds ago
## Version
cu102mkl 1.6.0.post0
## Minimal Reproduction
```python
from mxnet.gluon import HybridBlock
from mxnet.gluon.nn import Dense
from mxnet import nd
class MLP(HybridBlock):
def __init__(self, units, prefix=None):
super(MLP, self).__init__(prefix=prefix)
with self.name_scope():
self.layer = Dense(units, activation='sigmoid')
def hybrid_forward(self, F, x):
return self.layer(x)
model = MLP(100, prefix=None)
model.initialize()
test = nd.random.uniform(shape=(1, 100))
model.hybridize()
model.forward(test)
nd.waitall()
print(model.collect_params().keys())
model.export("mlp")
model.load_parameters('mlp-0000.params')
```
## Exception & Stack Trace
```
odict_keys(['mlp0_dense0_weight', 'mlp0_dense0_bias'])
Traceback (most recent call last):
File "test.py", line 29, in <module>
model.load_parameters('mlp-0000.params')
File
"/home/ubuntu/anaconda3/envs/tensorflow_p36/lib/python3.6/site-packages/mxnet/gluon/block.py",
line 530, in load_parameters
cast_dtype=cast_dtype, dtype_source=dtype_source)
File
"/home/ubuntu/anaconda3/envs/tensorflow_p36/lib/python3.6/site-packages/mxnet/gluon/parameter.py",
line 1012, in load
ignore_extra, restore_prefix, filename, cast_dtype, dtype_source)
File
"/home/ubuntu/anaconda3/envs/tensorflow_p36/lib/python3.6/site-packages/mxnet/gluon/parameter.py",
line 1047, in load_dict
name[lprefix:], error_str, _brief_print_list(arg_dict.keys()))
AssertionError: Parameter 'dense0_weight' is missing in file:
mlp-0000.params, which contains parameters: 'mlp0_mlp0_dense0_weight',
'mlp0_mlp0_dense0_bias'. Please make sure source and target networks have the
same prefix.
```
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]