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

bug in pytorch_lightning.metrics.functional.auroc #2670

Closed
BeHappyForMe opened this issue Jul 22, 2020 · 5 comments
Closed

bug in pytorch_lightning.metrics.functional.auroc #2670

BeHappyForMe opened this issue Jul 22, 2020 · 5 comments
Labels
bug Something isn't working help wanted Open to be worked on

Comments

@BeHappyForMe
Copy link

BeHappyForMe commented Jul 22, 2020

the code:

def validation_epoch_end(self, outputs):
        .........
        print(total_y_hat.device)
        print(total_y_true.device)
        print(total_y_hat)
        print(total_y_true)
        print(total_y_hat.shape)
        print(total_y_true.shape)
        auc_score = auroc(total_y_hat, total_y_true)

the output is:

Get data done!
Validation sanity check:  50%|█████     | 1/2 [00:00<00:00,  1.06it/s]

cuda:0
cuda:0
tensor([0.5084, 0.5084, 0.5084,  ..., 0.5084, 0.5084, 0.5084], device='cuda:0')
tensor([0., 0., 0.,  ..., 0., 0., 0.], device='cuda:0')
torch.Size([16384])
torch.Size([16384])
Traceback (most recent call last):
  File "lighting_sales.py", line 443, in <module>
    main(hparams)
  File "lighting_sales.py", line 392, in main
    trainer.fit(model)
  File "/opt/conda/lib/python3.7/site-packages/pytorch_lightning/trainer/trainer.py", line 918, in fit
    self.single_gpu_train(model)
  File "/opt/conda/lib/python3.7/site-packages/pytorch_lightning/trainer/distrib_parts.py", line 176, in single_gpu_train
    self.run_pretrain_routine(model)
  File "/opt/conda/lib/python3.7/site-packages/pytorch_lightning/trainer/trainer.py", line 1076, in run_pretrain_routine
    False)
  File "/opt/conda/lib/python3.7/site-packages/pytorch_lightning/trainer/evaluation_loop.py", line 330, in _evaluate
    eval_results = model.validation_epoch_end(outputs)
  File "lighting_sales.py", line 252, in validation_epoch_end
    auc_score = auroc(total_y_hat, total_y_true)
  File "/opt/conda/lib/python3.7/site-packages/pytorch_lightning/metrics/functional/classification.py", line 817, in auroc
    return _auroc(pred=pred, target=target, sample_weight=sample_weight, pos_label=pos_label)
  File "/opt/conda/lib/python3.7/site-packages/pytorch_lightning/metrics/functional/classification.py", line 766, in new_func
    x, y = func_to_decorate(*args, **kwargs)[:2]
  File "/opt/conda/lib/python3.7/site-packages/pytorch_lightning/metrics/functional/classification.py", line 815, in _auroc
    return roc(pred, target, sample_weight, pos_label)
  File "/opt/conda/lib/python3.7/site-packages/pytorch_lightning/metrics/functional/classification.py", line 553, in roc
    pos_label=pos_label)
  File "/opt/conda/lib/python3.7/site-packages/pytorch_lightning/metrics/functional/classification.py", line 504, in _binary_clf_curve
    torch.tensor([target.size(0) - 1])])
RuntimeError: All input tensors must be on the same device. Received cuda:0 and cpu
@BeHappyForMe BeHappyForMe added bug Something isn't working help wanted Open to be worked on labels Jul 22, 2020
@github-actions
Copy link
Contributor

Hi! thanks for your contribution!, great first issue!

@ydcjeff
Copy link
Contributor

ydcjeff commented Jul 22, 2020

That bug is fixed on master. See #2657

@BeHappyForMe
Copy link
Author

thank u very much

@awaelchli
Copy link
Member

Does it work with master branch? If not, do you use the functional or module interface for the metric?

@Borda Borda changed the title the "pytorch_lightning.metrics.functional.auroc" bug bug in pytorch_lightning.metrics.functional.auroc Jul 22, 2020
@edenlightning
Copy link
Contributor

@BeHappyForMe I'm closing this but please open if still experiencing this with master.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working help wanted Open to be worked on
Projects
None yet
Development

No branches or pull requests

4 participants