상세 컨텐츠

본문 제목

(pytorch) pytorch-tensor와 numpy-ndarray 간에 변환하기

프로그래밍/딥러닝

by 릿카。 2024. 9. 4. 13:16

본문

(1) ndarray -> tensor

a = np.array([1,2])
t = torch.from_numpy(a)

 

(2) tensor -> ndarray

t = torch.tensor([1,2])
a = t.numpy()

 

관련글 더보기

댓글 영역