DL&ML/code.data.tips

모델이 학습 이후에 모든 입력에 대해 동일한 출력을 내는 문제

식피두 2021. 5. 3. 20:53

유사도 판단을 위한 임베딩을 얻기 위해 

pretrained model을 가져다 fine-tuning을 통해 태스크에 좀 더 적합한 임베딩을 만들기 위해서

Arcface Loss를 학습을 했는데, 학습 후에 모든 입력에 대해 동일한 출력을 내는 기이한 현상을 겪었다.

 

Loss는 줄어드는 것을 보고 학습은 되고 있는게 아닌가 싶었는데...

 

아래 글에서 힌트를 얻어 확인해보니, 결국 Learning Rate이 너무 높은게 문제였다.

 

아마 이 때, ArcFace에 속한 FC Layer에 높은 LR을 부여하다가,

너무 큰 LR을 할당해버리는 바람에 학습이 이상하게 된 듯 싶다.

 

https://discuss.pytorch.org/t/outputs-from-a-simple-dnn-are-always-the-same-whatever-the-input-is/14969

 

Outputs from a simple DNN are always the same whatever the input is

I have built a DNN with only one hidden layer, the following are the parameters: input_size = 100 hidden_size = 20 output_size = 2 def init(): self.linear1 = nn.Linear() self.linear2 = nn.Linear() def forward(): x1 = F.leaky_relu() return F.leaky_relu() #u

discuss.pytorch.org