Pytorch : tensor 与 numpy 的 ndarray 相互转化 pytorch 张量与 numpy 数组之间转化

1. 转换方法:

1. tensor => ndarray : tensor.numpy()

2. ndarray => tensor : tensor = torch.from_numpy(ndarray)

posted @ 2022-02-25 10:30  咖啡陪你  阅读(157)  评论(0)    收藏  举报