Code Monkey home page Code Monkey logo

Comments (7)

qian-qi avatar qian-qi commented on July 17, 2024 1

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.

qian-qi avatar qian-qi commented on July 17, 2024

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.

Liudzz avatar Liudzz commented on July 17, 2024

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.

qian-qi avatar qian-qi commented on July 17, 2024

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.

Liudzz avatar Liudzz commented on July 17, 2024

Thank you!

from softtriple.

Liudzz avatar Liudzz commented on July 17, 2024

@qian-qi

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.

Liudzz avatar Liudzz commented on July 17, 2024

Thank you so much!

from softtriple.

Related Issues (16)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.