RuntimeError: result type Float can't be cast to the desired output type Long

2023. 1. 30. 22:38·Error Note
728x90
반응형
반응형

- 전체 에러 문구

RuntimeError: result type Float can't be cast to the desired output type Long

​

=> output 텐서와 target 텐서의 데이터 타입이 같지 않을 때 발생하는 에러입니다.

​

 

- 해결 방법

저의 경우에는 output 텐서는 float32 타입, target 텐서는 int64 타입이었습니다. 두 텐서의 데이터 타입을 동일하게 맞춰주었습니다. 따라서, target텐서를 float 타입으로 변경해주었습니다.

labels => labels.float()

self.loss(logits, labels.view([-1,1]).float(), alpha=0.75, reduction='mean')
728x90
반응형
저작자표시 (새창열림)

'Error Note' 카테고리의 다른 글

RuntimeError: view size is not compatible with input tensor's size and stride ~  (0) 2023.01.30
RuntimeError: grad can be implicitly created only for scalar outputs  (0) 2023.01.30
TypeError: can't convert cuda:0 device type tensor to numpy. Use Tensor.cpu() to copy the tensor,,,  (0) 2023.01.30
[Pytorch] RuntimeError: CUDA error: device-side assert triggered  (0) 2023.01.29
[Tensorflow] Invalid argument: Subshape must have computed start >= end since stride is negative,,,  (0) 2023.01.29
'Error Note' 카테고리의 다른 글
  • RuntimeError: view size is not compatible with input tensor's size and stride ~
  • RuntimeError: grad can be implicitly created only for scalar outputs
  • TypeError: can't convert cuda:0 device type tensor to numpy. Use Tensor.cpu() to copy the tensor,,,
  • [Pytorch] RuntimeError: CUDA error: device-side assert triggered
ga.0_0.ga
ga.0_0.ga
    반응형
    250x250
  • ga.0_0.ga
    ##뚝딱뚝딱 딥러닝##
    ga.0_0.ga
  • 전체
    오늘
    어제
    • 분류 전체보기 (195)
      • Paper Review (56)
        • Video Scene Graph Generation (6)
        • Image Scene Graph Generation (18)
        • Graph Model (5)
        • Key Information Extraction (4)
        • Fake Detection (2)
        • Text to Image (1)
        • Diffusion Personalization (4)
        • LLM & VLM (4)
        • etc (12)
      • AI Research (49)
        • Deep Learning (30)
        • Artificial Intelligence (15)
        • Data Analysis (4)
      • Pytorch (13)
      • ONNX (5)
      • OpenCV (7)
      • Error Note (35)
      • Linux (2)
      • Docker (3)
      • Etc (7)
      • My Study (16)
        • Algorithm (10)
        • Project (4)
        • Interview (2)
  • 블로그 메뉴

    • 홈
    • 태그
    • 방명록
  • 링크

  • 공지사항

  • 인기 글

  • 태그

    알고리즘
    JNI
    linear regression
    dataset
    forch.nn.functional
    그래프신경망
    Inductive bias
    TypeError
    transformer
    i3d
    3dinput
    ONNX
    정규화
    permute
    Logistic regression
    pytorch
    dataloader
    GCN
    torch.nn
    fine tuning
    contiguous
    차원의 저주
    pandas
    활성화 함수
    tensorflow
    오차 역전파
    Activation Function
    나이브 베이즈 분류
    RuntimeError
    HRNet
  • 최근 댓글

  • 최근 글

  • hELLO· Designed By정상우.v4.10.0
ga.0_0.ga
RuntimeError: result type Float can't be cast to the desired output type Long
상단으로

티스토리툴바