-
Notifications
You must be signed in to change notification settings - Fork 1
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
reshape data in dataset.py #3
Comments
We need to use negative samples to compute cross-entropy loss, which is a traditional training way in FM models. def fit_nll_neg(self, input_batch, epsilon=1e-9):
preds = torch.sigmoid(self.forward(input_batch))
cost = - torch.log(preds[:, 0] + epsilon).sum() - torch.log(1 - preds[:, 1:] + epsilon).sum()
return cost / preds.shape[0] In my data file, one positive sample is the first line and its negative samples follows. And the following is the second positive one. Repeat... So the raw data is shaped like (n_samples * (1 + neg_num) |
Hi @MogicianXD, Thanks for your reply. Is there any particular reason for using such a data format? Can you release an example of your data? |
No particular reason. The data format is determined by your data preprocessing. |
Thank you soooo much! |
Hi,
in line 10 of dataset.py file, it reshapes the feature to (1+neg_num, feature.shape[-1]).
What is neg_num? and why there is a need to reshape feature?
The text was updated successfully, but these errors were encountered: