RuntimeError: set_storage is not allowed on a Tensor created from .data or .detach().
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)
with torch.no_grad():
self.weight_hh.set_(weight_hh_data)
self.alpha_weight_hh.set_(alpha_weight_hh_data)
解决问题
你好👋 请问这个问题具体怎么解决呢?
你好👋 请问这个问题具体怎么解决呢?
版本不一致
升级pytroch版本或者,不升级改成上面的版本