[파이토치 (PyTorch)] IndexError: invalid index of a 0-dim tensor. Use tensor.item() to convert a 0-dim tensor to a Python number
0.5 이전 버전의 파이토치에서 작성된 코드를 0.5 이후 버전에서 돌리다 보면 위와 같은 에러가 날 때가 있습니다. 파이토치의 데이터 자료 구조가 바뀌어서 그렇습니다.
코드에서 변수.data[0] 인 부분을 변수.data 로 바꾸어주시면 해결됩니다.
참고한 곳: https://github.com/NVIDIA/flownet2-pytorch/issues/113#issuecomment-450802359
'인공지능' 카테고리의 다른 글
[토치 (Torch)] error: more than one operator "==" matches these operands (0) | 2018.12.07 |
---|---|
[쿠다, Cuda] CUDA, CUDNN 설치 여부 및 버전 확인 (0) | 2018.02.02 |
딥 러닝 용어 - batch, iteration, epoch (9) | 2017.01.12 |