wbawakate / fairtorch

PyTorch implementation of parity loss as constraints function to realize the fairness of machine learning.
MIT License
71 stars 8 forks source link

Demo not working #26

Open jakwisn opened 3 years ago

jakwisn commented 3 years ago

Hi! I was trying to run the demo.ipynb but found that it does not work for me

RuntimeError                              Traceback (most recent call last)
<ipython-input-12-87b1f64074ed> in <module>
     13     logit = model(X_train)
     14     loss = criterion(logit.view(-1), y_train)
---> 15     loss +=  dp_loss(X_train, logit, sensi_train)
     16     loss.backward()
     17     optimizer.step()

RuntimeError: Expected all tensors to be on the same device, but found at least two devices, cuda:0 and cpu!

Setting the selft.device to cpu fixes it but using gpu would be nice.

Great package btw :)

My system info: 
-----
fairtorch           NA
numpy               1.18.5
pydev_jupyter_vars  NA
sinfo               0.3.1
torch               1.7.1
-----
IPython             7.19.0
jupyter_client      6.1.7
jupyter_core        4.7.0
notebook            6.1.5
-----
Python 3.8.5 (default, Jul 28 2020, 12:59:40) [GCC 9.3.0]
Linux-5.4.0-52-generic-x86_64-with-glibc2.29
12 logical CPU cores, x86_64
-----
Session information updated at 2021-01-12 13:20
MasashiSode commented 3 years ago

thank you for your report! can you run this example?

jakwisn commented 3 years ago

That one works for me

MasashiSode commented 3 years ago

@jakwisn thank you! i beg the demo.ipynb is not updated. we will update it soon.

@akiFQC I think we need to update the demo.ipynb