삽질 기록 Pytorch 에서의 TopK error (k not in range for dimension) 2021. 5. 10. 16:11 - 728x90 반응형 pytorch 에서의 input tensor 에서 주어진 k 값에 따라 가장 큰 값 k 개를 찾는 함수이다. image classification 에서 train/validation 시 accuracy 측정할 때 자주 사용된다. 아래와 같은 에러는 TopK 범위를 잘못 지정하였을 때 나는 에러이다. RuntimeError: invalid argument 5: k not in range for dimension at /pytorch/aten/src/THC/generic/THCTensorTopK.cu:26 RuntimeError: invalid argument 5: k not in range for dimension at /pytorch/aten/src/THC/generic/THCTensorTopK.cu:26 당연한 이야기 이지만 TopK 범위는 class 갯수보다 적거나 같은 수여야 한다. 참고자료 1 : stackoverflow.com/questions/63463510/finding-the-top-k-matches-in-pytorch Finding the top k matches in Pytorch I'm using the following code to find the topk matches using pytorch: def find_top(self, x, y, n_neighbors, unit_vectors=False, cuda=False): if not unit_vectors: x = __to_unit_torch__(x,... stackoverflow.com 참고자료 2 : pytorch.org/docs/stable/generated/torch.topk.html torch.topk — PyTorch 1.8.1 documentation Shortcuts pytorch.org 728x90 반응형 공유하기 게시글 관리 구독하기Enough is not enough 저작자표시 비영리 카카오스토리 트위터 페이스북 '삽질 기록' 카테고리의 다른 글 Input type (torch.cuda.DoubleTensor) and weight type (torch.cuda.FloatTensor) should be the same (0) 2021.06.24 Ubuntu 18.04 환경에서 VNC Server 설정했을 때 회색 화면 나타나는 문제 (0) 2021.06.11 VNC viewer 에서 Pycharm 실행 시 DISPLAY 문제 (0) 2021.05.10 docker 에서 authentication required 문제 (0) 2021.03.08 /usr/bin/ld: cannot find -luuid (0) 2021.02.15 Contents 당신이 좋아할만한 콘텐츠 Input type (torch.cuda.DoubleTensor) and weight type (torch.cuda.FloatTensor) should be the same 2021.06.24 Ubuntu 18.04 환경에서 VNC Server 설정했을 때 회색 화면 나타나는 문제 2021.06.11 VNC viewer 에서 Pycharm 실행 시 DISPLAY 문제 2021.05.10 docker 에서 authentication required 문제 2021.03.08 NEXT VNC viewer 에서 Pycharm 실행 시 DISPLAY 문제 PREV Ubuntu 18.04 환경에서 VNC Server 설정했을 때 회색 화면 나타나는 문제 댓글 0 + 이전 댓글 더보기 비공개 댓글 남기기