. Numpy → Tensor
output = torch.Tensor(input) # 새로운 메모리에 할당.
output = torch.from_numpy(input) # 기존 메모리에 할당.
(where input is Numpy type, output is Tensor type)
2. Tensor → Numpy
output= np.array(input)
(where input is Tensor type, output is Numpy type)
(암기도 하려고 노력해야 외워진다.)
'인공지능 (기본 딥러닝) > 딥러닝 및 파이토치 기타 정리' 카테고리의 다른 글
[Convolution 의 Group 파라미터] torch.nn.Conv3d(group=1) (0) | 2024.02.03 |
---|---|
[파이썬 디버거] import pdb;pdb.set_trace() (0) | 2023.12.27 |
[1차원 추가 및 제거] Pytorch squeeze / unsqueeze (1) | 2023.12.23 |
[Cross entropy] 크로스 엔트로피의 index 값은 0부터 시작이다. (0) | 2023.12.23 |
[Pytorch] 모델 생성시, super().__init__() (0) | 2023.11.01 |