Git Product home page Git Product logo

Comments (2)

Haochen-Wang409 avatar Haochen-Wang409 commented on August 17, 2024

感谢您对我们工作的认可。

对比学习损失的权重设置为 0.1 的原因主要在于它的数量级较大。由于对比学习中温度超参设置为 0.5,在最好的情况下,正样本特征之间 cosine_similarity = 1,256 个负样本之间的 cosine_similarity = -1,此时经过 softmax 后,其概率分别为 0.1758 和 0.0032,导致它的损失为 1.74.

换言之,一个 “完美” 的模型,对比学习提供的 loss 将达到 1.74,对比 supervised loss 的量级 (后期可下降至 0.1),我们设定权重为 0.1

from u2pl.

Haochen-Wang409 avatar Haochen-Wang409 commented on August 17, 2024

您可通过以下代码进行数量级的估算

import torch
import torch.nn.functional as F

a = -torch.ones((1, 257))
a[0, 0] = 1
b = F.softmax(a / 0.5, dim=0)
labels = torch.zeros((1,)).long()
print(b, F.cross_entropy(a / 0.5, labels))

from u2pl.

Related Issues (20)

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.