Comments (4)
Hi,
thanks for reporting this. This issue is more related to the CA-TCC work, where we use the SupConLoss
.
To summarize what I understood:
you mean that the process of subtracting the maximum value from each row in the anchor_Dot_Contrast
tensor can lead to some extremely negative values in the logits
tensor, especially when there's a large disparity between the maximum value and other values in a particular row.
As a consequence, the exponential operation (torch.exp(logits))
and (torch.log(exp_logits.sum(1, keepdim=True)))
, can result in numerical instability, leading to values of NaN for the loss.
I think you are right, and this can be a valid point. We can address it in the implementation in several ways. For example, we can do clamping to the values of logits before performing the exponential operation. This can be to a predefined range.
Another way is to add a small constant before taking the logarithm to prevent the logarithm of a value close to zero.
It would be very beneficial if you can post the whole error message so that I can check and debug it properly.
from ts-tcc.
Yes, that's what I mean. During the training process, the loss becomes Nan, resulting in all weights becoming Nan, which will not lead to python errors.
But I can provide information on debugging SupConLoss:
- When entering 'forward':
- Before subtracting the maximum value:
- After subtracting the maximum value:
exp_logits = torch.exp(logits) * logits_mask
After exponential operation, it will become zero.
- When calculating
log_prob
, some calculation results become Nan due to-torch. log
Nan appeared in the final calculation of the loss:
My current solution is to add 'eps=1e-15' when calculating the row sum of 'exp_logits' to avoid zero. But will this lead to situations where losses cannot converge?
from ts-tcc.
If the eps
I set is too small, this error message will still appear:
from ts-tcc.
Thank you for your help! Perhaps I can use some methods to alleviate this problem myself.
from ts-tcc.
Related Issues (20)
- Produce macro-averaged F1-score (MF1) results HOT 2
- About training a new dataset HOT 3
- Some Questions
- question regarding the implementation of your temporal contrasting loss HOT 1
- there might be code error for augmentation? HOT 2
- Contextual Contrasting Loss Function HOT 1
- Badly in need of a pretrained model of epilepsy.Could anyone help? HOT 1
- Augmentations and # of training epochs HOT 1
- Obtaining labels on a completly unsupervised dataset HOT 1
- data augment HOT 1
- Can not repeat FD dataset preprocess HOT 3
- the process of self-supervised experiment HOT 5
- Loss cannot decrease HOT 1
- Problem with Augmentation HOT 4
- how to handle overfitting problem? HOT 2
- Problem with self_supervised mode training HOT 1
- Request for training logs and detailed settings HOT 5
- Add license HOT 1
- Something wrong with the code when i use self-supervised mode HOT 1
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 ts-tcc.