I want to add for anyone getting to this place that the code



 Brando_Miranda:

W.data.copy(new_value.data)


doesn’t work, since Tensors do not have a copy method.
Instead, use :
W.data.copy_(new_value.data)
Notice the underscore !