You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
안녕하세요 승균님! 주간학습 피드백에도 적어놓긴 했는데, train_model_reg.ipynb 보다가 수정할 부분 있는 것 같아 issue로 남깁니다. train_model_reg.ipynb 의 WeightedRandomSampler 구하는 부분 (7번째 셀) 에서 다음과 같이 samples_weight 구하는 코드에서 에러가 나는 것 같습니다.
## prepare sampler
from torch.utils.data.sampler import WeightedRandomSampler
weight = df_train[target].value_counts().sort_index().to_numpy()
print('count :', weight)
weight = 1. / weight
samples_weight = np.array([weight[t] for t in df_train[target]])
weight = df_train[target].value_counts().sort_index().to_numpy() 로 만드시면서 numpy array로 변환 되는 것 같고, df_train[target] 를 for loop 돌리면서 나이 값인 t로 weight를 selecting 하시는 것 같습니다.
현재 상황에서는 weight array의 길이보다 나이 값이 클 경우, (55세, 60세 등) weight[60] 과 같이 select 할때 index error가 나는것 같습니다.
의도하시는게 target에 해당하는 나이 값에 해당하는 1 / 빈도수 값을 가져오시려고 하는 것 같은데, weight를 numpy array로 사용하면 나이 값에 대한 index를 갖지 않으므로, pandas series를 사용해서 나이 값을 Index로 가지고, 1 / 빈도수 값을 가지도록 만드시면 원하시는 동작이 될 것 같습니다.
정말 꼼꼼히 봐주셔서 감사합니다 ㅠㅠ sampler같은 경우는 이 노츠북이 train_model을 복제해서 변형한거라 남아잇긴한데 사실
쓰진 않앗습니다.. 회귀문제에서도 분류문제와 같이불균형 데이터라는 개념이 잇는지 그걸 해결하기위해서 weighted sampler를
쓰는지를 잘 몰라서 안쓰긴 했는데 쓰는것이 좋은건지 궁금합니다!
2021년 9월 1일 (수) 오후 1:29, Jongsun Shinn ***@***.***>님이 작성:
안녕하세요 승균님! 주간학습 피드백에도 적어놓긴 했는데,
train_model_reg.ipynb
보다가 수정할 부분 있는 것 같아 issue로 남깁니다.train_model_reg.ipynb
의WeightedRandomSampler
구하는 부분 (7번째 셀) 에서 다음과 같이samples_weight
구하는 코드에서 에러가 나는 것 같습니다.weight = df_train[target].value_counts().sort_index().to_numpy()
로 만드시면서 numpy array로 변환 되는 것 같고,df_train[target]
를 for loop 돌리면서 나이 값인t
로weight
를 selecting 하시는 것 같습니다.현재 상황에서는
weight
array의 길이보다 나이 값이 클 경우, (55세, 60세 등)weight[60]
과 같이 select 할때 index error가 나는것 같습니다.의도하시는게 target에 해당하는 나이 값에 해당하는 1 / 빈도수 값을 가져오시려고 하는 것 같은데, weight를 numpy array로 사용하면 나이 값에 대한 index를 갖지 않으므로, pandas series를 사용해서 나이 값을 Index로 가지고, 1 / 빈도수 값을 가지도록 만드시면 원하시는 동작이 될 것 같습니다.
아래 브랜치와 커밋내용에 해당하는 노트북 기준으로 확인했습니다.
https://github.com/boostcampaitech2/image-classification-level1-16/blob/493e0a666944e7cdbaa8079b3fce613a3a180e18/train_model_reg.ipynb
The text was updated successfully, but these errors were encountered: