question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

SIP Finetune on CheXpert - Validation sanity check error - target has to be an integer tensor

See original GitHub issue

Hello, I am trying to finetune with train_sip.py and the public dataset CheXpert. At the moment, I simply launched the training by specifying one of the pretrained model available online and the dataset name and directory. Is there any other configuration step that should be made?

At the moment, i am getting the error “target has to be an integer tensor” during _basic_input_validation (see log below). When going back to the function validation_epoch_end (“sip_finetune.py”, line 213), i noticed that “targets” is defined as a Tensor - dtype = float32 , while “logits” values are in the range [-1,1]. I was expecting them to be between 0 and 1… is that right? What could I do to fix this?

Thank you in advance! Silvia

LOG: _Validation sanity check: 50%|█████ | 1/2 [00:00<00:00, 1.40it/s]path: Atelectasis, len: 64 Traceback (most recent call last):

File “/Facebook_NYU/CovidPrognosis-master/cp_examples/sip_finetune/train_sip.py”, line 205, in <module> cli_main(args)

[…] File “/Facebook_NYU/CovidPrognosis-master/cp_examples/sip_finetune/sip_finetune.py”, line 231, in validation_epoch_end self.val_acc[i](logits, targets)

File “/home/anaconda3/envs/facebook/lib/python3.9/site-packages/torch/nn/modules/module.py”, line 889, in _call_impl result = self.forward(*input, **kwargs)

File “/home/anaconda3/envs/facebook/lib/python3.9/site-packages/torchmetrics/metric.py”, line 152, in forward self.update(*args, **kwargs)

File “/home/anaconda3/envs/facebook/lib/python3.9/site-packages/torchmetrics/metric.py”, line 199, in wrapped_func return update(*args, **kwargs)

File “/home/anaconda3/envs/facebook/lib/python3.9/site-packages/pytorch_lightning/metrics/classification/accuracy.py”, line 138, in update correct, total = _accuracy_update(

File “/home/anaconda3/envs/facebook/lib/python3.9/site-packages/pytorch_lightning/metrics/functional/accuracy.py”, line 25, in _accuracy_update preds, target, mode = _input_format_classification(preds, target, threshold=threshold, top_k=top_k)

File “/home/anaconda3/envs/facebook/lib/python3.9/site-packages/pytorch_lightning/metrics/classification/helpers.py”, line 433, in _input_format_classification case = _check_classification_inputs(

File “/home/anaconda3/envs/facebook/lib/python3.9/site-packages/pytorch_lightning/metrics/classification/helpers.py”, line 296, in _check_classification_inputs _basic_input_validation(preds, target, threshold, is_multiclass)

File “/home/anaconda3/envs/facebook/lib/python3.9/site-packages/pytorch_lightning/metrics/classification/helpers.py”, line 62, in _basic_input_validation raise ValueError(“The target has to be an integer tensor.”)

ValueError: The target has to be an integer tensor._

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
nataschadamcommented, Apr 28, 2021

Hello @mmuckley , I am a colleague of @silgonel .

Thank you very much for your help. After the answer you gave us yesterday, we realized that even if we used the file “requirements” to create a new conda environment, conda didn’t install the required versions of the packages. We created a new conda environment manually installing the required packages, and fortunately, the problem is gone and the training is working. Thank you very much for your help!

1reaction
mmuckleycommented, Apr 28, 2021

@silgonel What version of PyTorch and PyTorch Lightning are you running? It looks like this error was thrown by Lightning. I was on 1.7.1 and 1.0.8.

EDIT: much apologies - I see you matched what is in the requirements.txt. I’ll try to match with the small version of CheXpert. Yes, you’re right, we use the large one.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Stop at Validation sanity check · Issue #2295 - GitHub
Hi, My code stops at Validation sanity check, there is no error, just stop right there How should I fix this issue? What...
Read more >
Validation sanity check - LightningModule - Lightning AI
Hi, I am new to pytorch lightning. Can someone explain what is validation sanity check ? Thanks in advance!
Read more >
PyTorch-Lightning trainer.fit() "Validation sanity check" fails ...
Solution: in the TestDataset , self.data is not defined; thus calling dataset.__len__ returns the AttributeError. The solution is to not ...
Read more >
adequacy - OSCHINA - 中文开源技术交流社区
A Framework for Checking Regression Test Selection Tools 对回归测试选择工具 ... 安全漏洞预测 CRADLE: Cross-Backend Validation to Detect and Localize Bugs in ...
Read more >
Computer Vision – ECCV 2020: 16th European Conference ...
Third column shows a simple sanity check: the visualisation of an untrained network of randomly initialised weights. The result is completely different, ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found