TIL/개인공부
2020. 1. 4.
[Pytorch] numpy에서 torch, torch에서 numpy
torch에서 numpy a = torch.randn(1,3) print(a) # tensor([[0.5519, 0.1323, 0.1297]]) b = a.numpy() print(b) # [[0.55190253 0.13231923 0.12974031]] numpy에서 torch a = np.ones(3) print(a) # [1. 1. 1.] b = torch.from_numpy(a) print(b) # tensor([1., 1., 1.], dtype=torch.float64)