Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

loss function #152

Open
riyajatar37003 opened this issue May 20, 2024 · 4 comments
Open

loss function #152

riyajatar37003 opened this issue May 20, 2024 · 4 comments
Labels
question Further information is requested

Comments

@riyajatar37003
Copy link

i am trying to understand the loss function :

def calc_loss(self, y_true, y_pred): """ 矩阵计算batch内的cos loss """ y_true = y_true[::2] norms = (y_pred ** 2).sum(axis=1, keepdims=True) ** 0.5 y_pred = y_pred / norms y_pred = torch.sum(y_pred[::2] * y_pred[1::2], dim=1) * 20 y_pred = y_pred[:, None] - y_pred[None, :] y_true = y_true[:, None] < y_true[None, :] y_true = y_true.float() y_pred = y_pred - (1 - y_true) * 1e12 y_pred = y_pred.view(-1) y_pred = torch.cat((torch.tensor([0]).float().to(self.device), y_pred), dim=0) return torch.logsumexp(y_pred, dim=0)

  1. why we are taking alternate values from true labels?
  2. why we are taking dot product between alternate ypred?

if possible can you share any link or documentation of paper for this. thanks

@riyajatar37003 riyajatar37003 added the question Further information is requested label May 20, 2024
@shibing624
Copy link
Owner

@riyajatar37003
Copy link
Author

thanks , but is there any english version?

@riyajatar37003
Copy link
Author

riyajatar37003 commented May 20, 2024

https://kexue.fm/archives/8847

in this article , what is mean by positive sample pairs and negative sample pairs?
does it mean as follow:
positve sample pair: (sent1, sent2,1)
negative sample pair: {sent1, sent3,0)

something like that

@shibing624
Copy link
Owner

yes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants