EfficietNet + Generalized Mean Pooling causes NaN loss!
See original GitHub issueConfig:
TF: 2.6
Environment: Colab
Issue
I’ve plugged a GeM pooling layer into the EfficientNet model but for an unknown reason, it causes nan
loss. But with other image-net models, it works just fine.
Reproducible Code
Issue Analytics
- State:
- Created 2 years ago
- Comments:8 (1 by maintainers)
Top Results From Across the Web
Common Causes of NANs During Training
Common Causes of NANs During Training · Gradient blow up · Bad learning rate policy and params · Faulty Loss function · Faulty...
Read more >Deep-Learning Nan loss reasons - python - Stack Overflow
There are lots of things I have seen make a model diverge. Too high of a learning rate. You can often tell if...
Read more >GeM Pooling Explained with PyTorch Implementation and ...
Therefore, today we will look at GeM Pooling and understand how it is different from the common Max and Average pooling techniques.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Given that this bug is not hit when trainable is false, we believe this might be an issue with zeros in
self.p
, which look like they would trigger a nan. You may need to try protecting against zero values in p in the custom GeM layer.@Jobayer-000 I think for GeM, this p needs to be trainable. Anyway, It’s solved now and I closed the issue.
ref. https://github.com/innat/DOLG-TensorFlow/blob/main/layers/GeM.py