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

RuntimeError: set_storage is not allowed on a Tensor created from .data or .detach(). #128

Open
actforjason opened this issue Jun 17, 2021 · 4 comments

Comments

@actforjason
Copy link

        weight_hh_data = torch.eye(self.hidden_size)
        weight_hh_data = weight_hh_data.repeat(1, 3)
        self.weight_hh.data.set_(weight_hh_data)
        
        alpha_weight_hh_data = torch.eye(self.hidden_size)
        alpha_weight_hh_data = alpha_weight_hh_data.repeat(1, 1)
        self.alpha_weight_hh.data.set_(alpha_weight_hh_data)

model\latticelstm.py", line 107, in reset_parameters
self.weight_hh.data.set_(weight_hh_data)
RuntimeError: set_storage is not allowed on a Tensor created from .data or .detach().
If your intent is to change the metadata of a Tensor (such as sizes / strides / storage / storage_offset)
without autograd tracking the change, remove the .data / .detach() call and wrap the change in a with torch.no_grad(): block.
For example, change:
x.data.set_(y)
to:
with torch.no_grad():
x.set_(y)

@actforjason
Copy link
Author

actforjason commented Jun 17, 2021

        with torch.no_grad():
            self.weight_hh.set_(weight_hh_data)
            self.alpha_weight_hh.set_(alpha_weight_hh_data)

解决问题

@yolanda182
Copy link

你好👋 请问这个问题具体怎么解决呢?

@WangYao-GoGoGo
Copy link

你好👋 请问这个问题具体怎么解决呢?

版本不一致

@WangYao-GoGoGo
Copy link

升级pytroch版本或者,不升级改成上面的版本

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

3 participants