본문 바로가기

반응형

Data-science/deep learning

(87)
[error-handling] ModuleNotFoundError: No module named 'german_transliterate' german_transliterate 설치를 해주면 된다. pip install git+https://github.com/repodiac/german_transliterate https://github.com/repodiac/german_transliterate GitHub - repodiac/german_transliterate: Python module to clean and transliterate (i.e. normalize) German text including abbrevia Python module to clean and transliterate (i.e. normalize) German text including abbreviations, numbers, timestamps etc. It..
[pytorch] AttributeError: module 'distutils' has no attribute 'version' 에러 해결 문제점 해결 pip install setuptools==59.5.0 https://github.com/pytorch/pytorch/issues/69894
[deep learning] e4e(encoder4editing) 를 이용한 연예인 얼굴 인코딩 (feat. IU 웃게 만들기) - 1탄 https://github.com/omertov/encoder4editing GitHub - omertov/encoder4editing: Official implementation of "Designing an Encoder for StyleGAN Image Manipulation" (SIGGRAPH 2 Official implementation of "Designing an Encoder for StyleGAN Image Manipulation" (SIGGRAPH 2021) https://arxiv.org/abs/2102.02766 - GitHub - omertov/encoder4editing: Official implementa... github.com pretrained-model을 이용해서 웃게 ..
[deep learning] vit-adapter를 이용한 애완동물 segmentation banmo에 나오는 segmentation 모델 바꿔보기... 기존 모델을 분석하자 과제는 위 동물에대해 segmentation을 진행하는 것이다. cfg.MODEL_WEIGHTS 가 보이는가? 거기에서 힌트를 찾을 수 있다. 기존 banmo의 경우 rcnnX101을 이용해서 instance segmentation을 진행하고 있었다. detectron2에서 나름 최신 pretrained model을 이용하고 있을거라 추정되는데... 과연 어떤 모델인지는 두고보자. detectron2는 뭐냐하면? https://github.com/facebookresearch/detectron2 GitHub - facebookresearch/detectron2: Detectron2 is a platform for obje..
[pytorch] Expected cuda got cpu, 혹은 타입 에러 발생시 내가 주로 사용하는 함수는 torch.FloatTensor() torch.LongTensor() 인데 이게 안 먹는 경우가 있다. 그럴 경우 .float() .long() 으로 하면 된다.
[pytorch] one-hot encoding이 반드시 필요할까? 그렇지 않다. F.cross_entropy 에선 one-hot 인코딩을 하지 않아도 cross entropy loss를 잘 계산해준다. 예를 들어 카테고리가 3개라고 하면 pred 값은 (B, 3) 형태일 것이다. B는 배치 사이즈 이때 target의 형태는 [B] 이면 된다. 각 Batch 마다 하나의 값을 int 값으로 갖고 있으면 된단 말이다. pytorch 에선 .long()으로 케스팅해주면된다. [B, 3]처럼 one-hot encoding 해줄 필요 없음. Is One-Hot Encoding required for using PyTorch's Cross Entropy Loss Function? Is One-Hot Encoding required for using PyTorch's Cross E..
[pytorch] pytorch cross entropy  사용시 주의할 점, tf sparse categorical cross entropy in pytorch? softmax가 이미 F.cross_entropy에 포함되어 있다. 따로 레이어에 추가히지 말자. LSTM 구현 예제 1. return_sequences가 없을 때 hidden_dim = 75 #150 class SimpleLSTM(LightningModule): def __init__(self, input_features, output_features, batch_first, num_classes): super(SimpleLSTM, self).__init__() self.lstm = nn.LSTM(input_size=input_features, hidden_size=output_features, batch_first=batch_first) self.linear = nn.Linear(output_feat..
[pytorch] RuntimeError: 0D or 1D target tensor expected, multi-target not supported 에러 nn.CrossEntropyLoss() 혹은 F.cross_entropy 를 사용했을 때 나타나는 에러일 것이다. nn.CrossEntropyLoss()(pred, target) 이렇게 계산이 되는데 가령 pred의 shape의 [ B, C]라면 C는 클래스 갯수 B는 배치 사이즈 target의 shape은 [B] 가 되어야 하는데 [B, 1]이렇게 돼서 문제가 발생하는 거다. 그래서 문제를 해결하려면 target의 shape를 축소해주자. nn.CrossEntropyLoss()(pred, target.squeeze(dim=-1)) https://pytorch.org/docs/stable/generated/torch.nn.CrossEntropyLoss.html CrossEntropyLoss — PyTor..

728x90
반응형