yitu-opensource / T2T-ViT

ICCV2021, Tokens-to-Token ViT: Training Vision Transformers from Scratch on ImageNet
Other
1.14k stars 177 forks source link

[maybe a bug] loss nan #69

Open xmy0916 opened 2 years ago

xmy0916 commented 2 years ago

https://github.com/yitu-opensource/T2T-ViT/blob/main/models/token_performer.py#L18 My code has turned on fp16, so the 1e-8 on this line to prevent division by 0 is not enough for my code... the loss of the network calculation appears nan due to this code : https://github.com/yitu-opensource/T2T-ViT/blob/main/models/token_performer.py#L50

yuanli2333 commented 2 years ago

Yes, you may be right, we can try to change 1e-8 to a large one, did you try it?

xmy0916 commented 2 years ago

@yuanli2333 I have tested 1e-4 but also can't fix the problem.

jiawangbai commented 2 years ago

@xmy0916 In my implementation, 1e-6 can fix this problem, with bs=2048 and lr=1e-3.

xmy0916 commented 2 years ago

Thanks!