question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

EfficietNet + Generalized Mean Pooling causes NaN loss!

See original GitHub issue

Config:

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:closed
  • Created 2 years ago
  • Comments:8 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
mattdangerwcommented, Nov 11, 2021

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.

0reactions
innatcommented, Feb 21, 2022

@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

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found