티스토리 뷰
Computer/이게 왜 안되지?
[이왜안?] KeyError: 0 / 숫자가 매번 바뀜 / DataLoader Key error날 때
벼랑끝과학자 2024. 4. 18. 14:33
위와 같이 torch의 DataLoader를 사용해서 데이터를 iteration 할때 매번 뭔가 이상하게 KeyError 값이 변하면서 데이터 확인이 안되고 에러가 나고 있다.
이때 만약 내 데이터가 Pandas의 DataFrame 타입이라면 torch.Dataset으로 train_dataset으로 만들어주는 코드에서 iloc를 빼먹지 않았는지 확인해보자
class BinaryDataset(Dataset):
def __init__(self, feature, target):
self.feature = feature
self.target = target
def __len__(self):
return len(self.target)
def __getitem__(self, idx):
return self.feature[idx], self.target[idx] # iloc를 빼먹은 코드
class BinaryDataset(Dataset):
...
def __getitem__(self, idx):
return self.feature.iloc[idx], self.target.iloc[idx] # iloc를 정상적으로 추가한 코드
'Computer > 이게 왜 안되지?' 카테고리의 다른 글
댓글
공지사항
최근에 올라온 글
최근에 달린 댓글
- Total
- Today
- Yesterday
TAG
- 오일석기계학습
- 이왜안
- 백준
- eigenvector
- 인공지능
- 최대우도추정
- Matrix algebra
- elementry matrix
- 3B1B따라잡기
- marginal likelihood
- eigenvalue
- ai인공지능
- 기계학습
- MLE
- 선형대수
- kl divergence
- 3b1b
- MatrixAlgebra
- kld
- manimtutorial
- vae
- variational autoencoder
- ai신약개발
- Manimlibrary
- MorganCircularfingerprint
- manim library
- manim
- 제한볼츠만머신
- 파이썬
- 베이즈정리
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
글 보관함