Roc_curve usage with float

Hello Dear all,

My network(CNN) has one output and activation function is sigmoid, so I have output values between [0 1]. My labels are just 0 and 1 {0,1}. My purpose is determine an image whether consists and a specific object or not. And also I try to plot roc curve but I have an issue. I describe it briefly;

I have two arrays, one is y_pred(is used to store network predictions) other is y_true(is used to store “true values”/“labels”). During the test, I append predictions to y_pred, and labels to y_true.

At the end of the test, I am calling below functions to plot roc curve.

fpr, tpr, _ = roc_curve(y_true, y_pred)
roc_auc = auc(fpr, tpr)

However, I am getting the below error. Could anyone help me?

File “/usr/local/lib/python3.5/dist-packages/torch/autograd/variable.py”, line 125, in bool
torch.typename(self.data) + " is ambiguous")
RuntimeError: bool value of Variable objects containing non-empty torch.ByteTensor is ambiguous
Process finished with exit code 1

It sounds like you’re trying to do the following:

tensor  # some random tensor
if tensor == 1:
    pass   # do something else

The error above happens when you’re trying to treat a ByteTensor (the result of a comparison) as a boolean.