Comments (7)
Hi, you can obtain the probability over all classes as: prob = F.softmax(self.la*simClass, dim=1). BTW, a larger feature dimension, e.g., 512, usually can improve the performance.
from softtriple.
Hi, besides the lr, you may try to reduce the value of lambda to a small one, e.g., 10, for a smooth optimization.
from softtriple.
Thank you so much for your answer !
I have turned lambda to 10 and center to 3 , it works well !
But in my project (a long tail dataset for classification), I use ResNet-18 as training model and train from scratch . To compare SoftTriple with cross entropy , I fix most parameters . The differences are last fc layer , the output dim of model of SoftTriple changed from class numbers (247) to 64 , and putting the parameters of loss function into optimizer . To my surprise,the accuracy of SoftTriple is a little bit (about 0.5%) smaller than CE !
For me , I think the hyperparameters of loss function need to be fine tuned , do you have any advice on it?
Thank you ! Have a good day !
from softtriple.
Hi, first you can set K=1 to check if it can reproduce the performance of CE with the appropriate setting. After that, you may tune parameters for SoftTriple, e.g., gamma, K, etc. to obtain the additional gain.
from softtriple.
Thank you!
from softtriple.
Sorry for trouble you again!
When I try to use SoftTriple loss for classification task , you know that for most model the output dim is equal to class number and we can get probabilities of each class. To use SoftTriple loss , I change the dim of model from class number to 64 as in your code . For measuring, I use self.la*(simClass-marginM) in loss function as probabilities of each class.Because I think we usually put output preds and labels into loss function (lossClassify = F.cross_entropy(self.la*(simClass-marginM), target)). I don't know whether it is correct ?
In your validate function,you use the code:
sim = X.dot(X.T)
minval = np.min(sim) - 1.
sim -= np.diag(np.diag(sim))
sim += np.diag(np.ones(num) * minval)
indices = np.argsort(-sim, axis=1)[:, : kmax]
YNN = Y[indices]
can I take YNN as the Top K output class to calculate accuracy ? Can we take YNN[i][0] as the t predict top-1 class? I am a little confused about this code.
from softtriple.
Thank you so much!
from softtriple.
Related Issues (16)
- proof of proposition1 HOT 1
- centers = F.normalize(self.fc, p=2, dim=0) what is its purpose? HOT 1
- proposition1 HOT 1
- The BatchNorm layers are not completely frozen HOT 1
- train loss HOT 3
- can you explain the recall@k? HOT 2
- pretrained models HOT 2
- out of memory error HOT 4
- softtriploss param HOT 1
- Code and Paper don't seem to match... HOT 2
- Out of Memory error when training on big number of classes HOT 2
- Clarification on gamma and lambda HOT 2
- MemoryError: Unable to allocate 113. GiB for an array with shape (122994, 122994) and data type float64 HOT 1
- Question - data with unit length HOT 1
- Centers
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 softtriple.