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

Failing to reproduce the code #1

Open
paulagd opened this issue Feb 18, 2021 · 2 comments
Open

Failing to reproduce the code #1

paulagd opened this issue Feb 18, 2021 · 2 comments

Comments

@paulagd
Copy link

paulagd commented Feb 18, 2021

Hi,

I'm trying to run your code and i'm getting an error on the evaluation function. Could you please tell me what am I doing wrong?

    > CUDA_VISIBLE_DEVICES=1 python run_ngcf.py --dataset ml-100k
    n_users=943, n_items=1682
    n_interactions=100000
    n_train=80064, n_test=19936, sparsity=0.06305
    Creating interaction matrices R_train and R_test...
    Complete. Interaction matrices R_train and R_test created in 1.9346222877502441 sec
    Loaded adjacency-matrix (shape: (2625, 2625) ) in 0.051796674728393555 sec.
    Initializing weights...
    Weights initialized.
    Start at 2021-02-18 18:04:15.554979
    Using cuda for computations
    Params on CUDA: True
    Epoch: 0, Training time: 8.75s, Loss: 30.0306
    Traceback (most recent call last):
      File "run_ngcf.py", line 107, in <module>
        k)
      File "/home/pgd721/work/NGCF_pytorch/utils/helper_functions.py", line 142, in eval_model
        pred_items.scatter_(dim=1, index=test_indices, src=torch.tensor(1.0).cuda())
    RuntimeError: Index tensor must have the same number of dimensions as src tensor

Thank you very much!

@goohanjun
Copy link

line 137, 140 must be
pred_items.scatter_(dim=1, index=test_indices,src=torch.ones_like(test_indices).float().cuda())
topk_preds.scatter_(dim=1, index=test_indices[:, :k], src=torch.ones_like(test_indices[:, :k]).float().cuda())

@Lim-Sung-Jun
Copy link

line 137, 140 must be pred_items.scatter_(dim=1, index=test_indices,src=torch.ones_like(test_indices).float().cuda()) topk_preds.scatter_(dim=1, index=test_indices[:, :k], src=torch.ones_like(test_indices[:, :k]).float().cuda())

thanks a lot!

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

No branches or pull requests

3 participants