Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

There's a bug in Ch10's “Implementation_of_Recurrent_Neural_Networks_from_Scratch”。 #110

Open
onbigion13 opened this issue Jul 4, 2020 · 0 comments

Comments

@onbigion13
Copy link

there is a runtime error when running the 7th code block. But I checked, the device type doesn't conflict each other. What's Wrong?

RuntimeError Traceback (most recent call last)
in
1 state = init_rnn_state(X.shape[0], num_hiddens, ctx)
2 inputs = to_onehot(X.to(ctx), len(vocab))
----> 3 params = get_params()
4 outputs, state_new = rnn(inputs, state, params)
5 len(outputs), outputs[0].shape, state_new[0].shape

in get_params()
9
10 # Hidden layer parameters
---> 11 W_xh = _one((num_inputs, num_hiddens))
12 W_hh = _one((num_hiddens, num_hiddens))
13 b_h = torch.zeros(num_hiddens, device=ctx)

in _one(shape)
6 def get_params():
7 def one(shape):
----> 8 return torch.Tensor(size=shape, device=ctx).normal
(std=0.01)
9
10 # Hidden layer parameters

RuntimeError: legacy constructor for device type: cpu was passed device type: cuda, but device type must be: cpu

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

No branches or pull requests

1 participant