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

p2ch14: TypeError: linspace() missing 1 required positional arguments: "steps" #93

Open
cmosguy opened this issue May 30, 2022 · 2 comments

Comments

@cmosguy
Copy link

cmosguy commented May 30, 2022

So I am getting the following error on this line :

threshold = torch.linspace(1, 0)

TypeError: linspace() missing 1 required positional arguments: "steps"
threshold = torch.linspace(1, 0)
tpr = (metrics_t[None, METRICS_PRED_P_NDX, posLabel_mask] >= threshold[:, None]).sum(1).float() / pos_count
fpr = (metrics_t[None, METRICS_PRED_P_NDX, negLabel_mask] >= threshold[:, None]).sum(1).float() / neg_count
fp_diff = fpr[1:]-fpr[:-1]
tp_avg  = (tpr[1:]+tpr[:-1])/2

Not sure why linspace was used if the threshold was supposed to be a constant. Does anyone know what the proper fix is?

@apoorvakashi
Copy link

If you see in chapter 14 of the book, we're trying to calculate the ROC/AUC metrics. For that, we're considering multiple thresholds between 0 and 1.
So I think this might work.
threshold = torch.linspace(1,0, steps = 5)

@Rockung
Copy link

Rockung commented Oct 24, 2023

From PyTorch 1.11 linspace requires the steps argument. Use steps=100 to restore the previous behavior.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants