Describe the bug
When using 'auc_roc_score' as one of the tabular model metrics, at the end of the 1st epoch you get the following error:
RuntimeError: Expected object of backend CUDA but got backend CPU for sequence element 1 in sequence argument at position #1 'tensors'
Execution of the notebook fails.
Provide your installation details
=== Software ===
python : 3.6.8
fastai : 1.0.51.dev0
fastprogress : 0.1.20
torch : 1.1.0a0+be364ac
nvidia driver : 418.39
torch cuda : 10.1.105 / is available
torch cudnn : 7500 / is enabled
=== Hardware ===
nvidia gpus : 1
torch devices : 1
- gpu0 : 8119MB | GeForce GTX 1070 Ti
=== Environment ===
platform : Linux-4.15.0-47-generic-x86_64-with-debian-stretch-sid
distro : Ubuntu 16.04 xenial
conda env : Unknown
python : /opt/conda/bin/python
sys.path :
/opt/conda/lib/python36.zip
/opt/conda/lib/python3.6
/opt/conda/lib/python3.6/lib-dynload
/opt/conda/lib/python3.6/site-packages
/opt/conda/lib/python3.6/site-packages/torchvision-0.2.3-py3.6.egg
/Docker/workdir/fastai
To Reproduce
learn = tabular_learner(data, layers=[200,100], metrics=[accuracy, auc_roc_score])
Expected behavior
The notebook should complete execution, with the additional metric.
Screenshots
Additional context
Running inside 'nvcr.io/nvidia/pytorch:19.03-py3' Docker container, under Ubuntu 18.04.
This is now fixed in master. Please note that auc_roc_score won't work directly, you have to use the AUROC() metric (unless your outputs have the same size as your targets, but that's not the case in this tabular example).
Many thanks @sgugger I tried that earlier, and got an error from _init_ saying it got 3 params not 1, will do a bit more reading :)
@benvenutto I'm currently getting the same thing. Any luck?
This seems to work:
learner = tabular_learner(train_data, layers=[2000, 100], metrics=[accuracy, AUROC()])
You need to instantiate AUROC as it's a class, not function, which wraps the metric. Which is exactly as @sgugger replied above, I wasn't paying attention :(
Most helpful comment
This seems to work:
learner = tabular_learner(train_data, layers=[2000, 100], metrics=[accuracy, AUROC()])You need to instantiate AUROC as it's a class, not function, which wraps the metric. Which is exactly as @sgugger replied above, I wasn't paying attention :(