본문 바로가기
  • Staying curious, growing through questions
Python/Error

[error] Input type (torch.cuda.FloatTensor) and weight type (torch.FloatTensor) should be the same

by Evergreen Mind 2023. 6. 16.

 

 

for i , (inputs, labels)   in enumerate(trainloader, 0):
        inputs, labels = inputs.to(device), labels.to(device)
        optimizer.zero_grad()

        #### error 가 난 위치
        outputs = net(inputs)
        ####
        loss = criterion(outputs, labels)

input은 device("cuda") 로 설정해준반면 모델인 net는 설정해주지 않아 발생한 에러이다.