Coder Social home page Coder Social logo

Comments (4)

AndrewAtanov avatar AndrewAtanov commented on July 22, 2024 3

Oh, I see. I think this is in part to avoid feature collapsing when all the vectors are pointing almost in the same direction. This effect is studied here [1], for example.

[1] https://generallyintelligent.ai/understanding-self-supervised-contrastive-learning.html

from simclr-pytorch.

AndrewAtanov avatar AndrewAtanov commented on July 22, 2024

Hi Nima,

Thanks for the interest. I cannot recall where the reference for that is, or maybe I'm confused, and there is no such. BN w/o bias term is also used in the official implementation [1], and, I guess, this is where I found this.

My intuition is as follows: in the contrastive NT-Xent loss, the cosine similarity is used, so image embeddings are treated as centered at 0. The bias term will break this assumption and also add the additive term in the embeddings interaction (the dot-product becomes: x^Ty + (x+y)^Tb + b^Tb). I'm not sure, though, how important this detail is for pretraining, it doesn't seem like a hard constraint from the theoretical point of view. If I recall correctly, there were issues when pretraining w/ the bias term in practice.

[1] https://github.com/google-research/simclr/blob/dec99a81a4ceccb0a5a893afecbc2ee18f1d76c3/model_util.py#L141

from simclr-pytorch.

nimaous avatar nimaous commented on July 22, 2024

Andrew, thanks a lot for your reply. I can understand why to set bias=Flase and your intuition completely make sense for me. but my question is why use a BN as the last layer instead of a linear layer? isn't that the cosine similarity does the centering and makes a uni hypersphere latent space?

from simclr-pytorch.

nimaous avatar nimaous commented on July 22, 2024

thanks. that was helpful

from simclr-pytorch.

Related Issues (13)

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.