728x90
손실함수에서 에러가 발생했습니다
데이터를 GPU에 저장하기 전에 대상 유형을 변환하면 됩니다.
아래와 같이 label을 LongTensorㅇ로 캐스팅 해주면 됩니다.
for inputs, targets in data_loader:
targets = targets.type(torch.LongTensor) # casting to long
inputs, targets = inputs.to(device), targets.to(device)
...
...
loss = self.criterion(output, targets)
for epoch in range(num_epochs):
for (words, labels) in train_loader:
words = words.to(device)
labels = labels.type(torch.LongTensor) # <---- Here (casting)
labels = labels.to(device)
'파이썬 > 파이썬 기초' 카테고리의 다른 글
cv2.imshow "The function is not implemented. Rebuild the library" #18 (6) | 2023.01.13 |
---|---|
albumentations ERROR: Could not install packages due to an OSError: [WinError 5] 액세스가 거부되었습니다: (16) | 2023.01.13 |
Python을 활용 Word 파일 생성 및 내용 수정 (18) | 2022.12.29 |
Python을 활용 Excel 파일 생성 및 내용 수정 (9) | 2022.12.29 |
파이썬 pandas columns 인덱스삭제(컬럼명이 같을 경우) (0) | 2022.12.14 |