torch中tensor 转 numpy array

import numpy as np
a = np.ones(5)
b = torch.from_numpy(a)
np.add(a, 1, out=a)
print(a)
print(b)
print(a)


a = torch.ones(5)
print(a)
b = a.numpy()
print(b)
posted @ 2021-10-14 19:33  呦呦南山  阅读(220)  评论(0编辑  收藏  举报