创建WxW张量:
x = Variable(torch.FloatTensor(W,W).zero_(), requires_grad=True)
做一些计算:
x_copy = x0=np.copy(x.data.numpy())
x_upd = handleArray(x_copy)
如何从x_upd分配x数据?
答案 0 :(得分:0)
考虑使用tensor.from_numpy()
https://pytorch.org/tutorials/beginner/former_torchies/tensor_tutorial.html
答案 1 :(得分:0)
好的,解决方案是:
x.data.from_numpy(x_upd)