nn.Transformer를 활용하다가 Evaluation Mode 중 sequence length가 변하는 문제가 발생했다. 

 

Batch, sequence, feature 인데 Train때는 max length 인 65가 잘 나오다가 Evaluation 에서 바로 에러가 발생했다. 

 

현재 나의 버전은 1.13.1+cu117 이다. 

 

pytorch 커뮤니티에서 해당 내용을 찾을 수 있었다. 

 

https://discuss.pytorch.org/t/torch-no-grad-changes-sequence-length-during-evaluation-mode/186176

 

Torch.no_grad() Changes Sequence Length During Evaluation Mode

I built a TransformerEncoder model, and it changes the output’s sequence length if I use “with torch.no_grad()” during the evaluation mode. My model details: class TransEnc(nn.Module): def __init__(self,ntoken: int,encoder_embedding_dim: int,max_item

discuss.pytorch.org

 

버전을 다운그레이드 하라고 나와서, 해당 글 안에있는 버전으로 다시 다운그레이드를 진행했다.

우선 

pip uninstall torch torchvision torchaudio

 

해당 명령어로 uninstall 해주었다. 

pip install torch==1.12.1+cu116 torchvision==0.13.1+cu116 torchaudio==0.12.1 --extra-index-url https://download.pytorch.org/whl/cu116

 

 

쿠다까지 확인하고 

shape 도 제대로 나오는것 확인했다!

버전 문제였다뉘,,,

 

 

+ Recent posts