Comments (5)
Thank you for your interest in our work!
I check the code released and make sure that the operations {division, log, and sqrt} have added an eps.
But, You can try to clamp the input of the POW operation to a range greater than 0, i.e., sine = torch.sqrt((1.0 - torch.pow(cosine.(0.0,1.0), 2)).clamp(0.0001, 1.0)) in 152 lines of utils.py, because torch.pow(a) = nan when a < 0.
If the above operation cannot address your problem, you can try to use the torch.nn.utils.clip_grad_norm_ operation to clip gradient norm of an iterable of parameters.
If the above suggestions solve your problem, I hope you can let me know so that I can update the code, thanks!!
from mpscl.
Alternatively, you can try clamping the input of torch.sqrt() to a larger scale, e.g., sine = torch.sqrt((1.0 - torch.pow(cosine.(0.0,1.0), 2)).clamp(0.1, 1.0)).
Because, the grad of torch.sqrt 1/torch.sqrt(x), if x = 0.0001, the grad = 10000
from mpscl.
Thanks for the response and for the advice. I found that line 35 of loss.py is causing my problem. When I removed the weight parameter from loss = F.cross_entropy(input=pred,target=label,weight=weight), I no longer got the issue with nan. But when the weight parameter is there, loss has the value nan.
from mpscl.
Thanks for your reply!
I will check the code again.
from mpscl.
Thanks to Feng Wei from Zhejiang University. We found that the instability of the training may be due to the exceptionally small (close to zero) weights of the background classes.
from mpscl.
Related Issues (13)
- The warmup CT2MR pre-trained model. HOT 3
- How to initialize the category center HOT 2
- About the cosine similarity between the pixel feature and the anchor HOT 2
- train on another dataset HOT 3
- Reproduction of the results of the paper. HOT 5
- pretrain on source domain HOT 3
- how to train from scratch HOT 9
- 训练过程中损失几个iter后变为nan HOT 2
- about supervised training HOT 1
- shape error HOT 2
- CLASS_CENTER_FEA_INIT HOT 2
- data processing HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from mpscl.