Notice
Recent Posts
Recent Comments
Link
| 일 | 월 | 화 | 수 | 목 | 금 | 토 |
|---|---|---|---|---|---|---|
| 1 | ||||||
| 2 | 3 | 4 | 5 | 6 | 7 | 8 |
| 9 | 10 | 11 | 12 | 13 | 14 | 15 |
| 16 | 17 | 18 | 19 | 20 | 21 | 22 |
| 23 | 24 | 25 | 26 | 27 | 28 | 29 |
| 30 |
Tags
- Linux
- OpenCV
- pytorch
- VS Code
- Selenium
- error
- pandas
- 핑거스타일
- 컨테이너
- windows forms
- 기타 연주
- mysql
- 프로그래머스
- JSON
- ubuntu
- Numpy
- paramiko
- 채보
- label
- Docker
- C
- C#
- 오류
- pip
- Python
- C++
- SSH
- nvidia-smi
- YOLO
- Visual Studio
Archives
- Today
- Total
기계는 거짓말하지 않는다
PyTorch RuntimeError: Input type (~) and weight type (~) should be the same 본문
AI
PyTorch RuntimeError: Input type (~) and weight type (~) should be the same
KillinTime 2023. 5. 13. 00:10PyTorch 모델 사용 시, 입력 텐서와 가중치 텐서의 데이터 유형이 서로 일치하지 않을 때 발생할 수 있는 오류이다.
아래는 오류 내용들이다.
| RuntimeError: Input type (torch.FloatTensor) and weight type (torch.cuda.FloatTensor) should be the same or input should be a MKLDNN tensor and weight is a dense tensor |
| RuntimeError: Input type (torch.cuda.HalfTensor) and weight type (torch.cuda.FloatTensor) should be the same ~ |
to() method를 이용해 같은 데이터 유형으로 만들어주면 된다.
# 예시 1
input = input.to(torch.float32)
# 예시 2
# 모델 가중치, 연산을 반 정밀도(half precision)로 변환할 때
device = 'cuda' if torch.cuda.is_available() else 'cpu'
model.half().to(device)
input = input.half().to(device)'AI' 카테고리의 다른 글
| YOLO 텍스트 라벨을 이용하여 Object Crop 이미지 저장 (0) | 2024.06.12 |
|---|---|
| YOLO 텍스트 라벨을 이미지에 bbox 표시, 시각화 (0) | 2023.12.25 |
| TensorFlow keras model fit UnimplementedError: Graph execution error (0) | 2023.05.05 |
| torch load_state_dict model key 변경 (0) | 2023.02.03 |
| Darknet make libdarknet.so (0) | 2022.11.04 |
Comments