Skip to content
This repository has been archived by the owner on Nov 17, 2023. It is now read-only.

[Bug] Unrecognize parameter shape after npx.set_up() #16098

Open
VoVAllen opened this issue Sep 5, 2019 · 4 comments
Open

[Bug] Unrecognize parameter shape after npx.set_up() #16098

VoVAllen opened this issue Sep 5, 2019 · 4 comments

Comments

@VoVAllen
Copy link

VoVAllen commented Sep 5, 2019

Description

In MXNet:

from mxnet.gluon import nn
print(nn.Dense(32).collect_params())  # weight shape=(32,0)

After importing dgl:

from mxnet import npx
npx.set_up()
from mxnet.gluon import nn
print(nn.Dense(32).collect_params())  # weight shape=(32,-1)

Basically, it is not a problem when creating, training & saving models.
However, when loading models from files by net.load_parameters(filename), it throws errors like:
shape (32,-1) is incompatible with shape (32, 8).
So we cannot correctly load the model by using the current API.

Related issue: dmlc/dgl#829

@mxnet-label-bot
Copy link
Contributor

Hey, this is the MXNet Label Bot.
Thank you for submitting the issue! I will try and suggest some labels so that the appropriate MXNet community members can help resolve it.
Here are my recommended label(s): Bug

@reminisce
Copy link
Contributor

reminisce commented Sep 5, 2019

It looks like you saved a net which has not been initialized. It should work like the following. However, recent changes on ndarray indexing has prevented assigning a legacy NDArray to mxnet.numpy.ndarray. So the load function cannot work now which is different issue than this one. I will submit a PR to fix this.

from mxnet import npx, np
npx.set_np()
from mxnet.gluon import nn
print(nn.Dense(32).collect_params())  # weight shape=(32,-1)

net = nn.Dense(32)
net.initialize()
net(np.ones((4, 11)))
print(net.collect_params())  # weight shape=(32,-1)

net.save_parameters('test.params')
net.load_parameters('test.params')
print(net.collect_params())

@reminisce reminisce added the Numpy label Sep 5, 2019
@samskalicky
Copy link
Contributor

@zachgk add [bug]

@samskalicky
Copy link
Contributor

@zachgk assign [@reminisce ]

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

6 participants