본문 바로가기
데이터분석/Pytorch

[Pytorch] Tensor(텐서) 오류 해결 모음

by Kc93 2022. 11. 28.
728x90
반응형
RuntimeError : expected scalar type Double but found Float

python

 

Pytorch는 Tensor연산시 Float32으로 진행

해결 : Float32로 바꿔주기. 

EX) sample_tensor.to(device, dtype=torch.float32)   

 

Expected all tensors to be on the same device, but found at least two devices

사용하는 텐서가 두종류(CPU,GPU)가 충돌한다는 의미

해결 : sample_tensor.CPU(), sample_tensor.GPU()를 사용하여 텐서의 흐름을 통일 시켜주기

반응형

댓글