Skip to content
Discussion options

You must be logged in to vote

Okay, I found the problem.

  • In the threshold version the problem was that
    voutputs_bin=torch.nn.functional.threshold(voutputs_bin,threshold=0.5,value=1)
    does not binarize the tensor. It sets everything under 0.5 to 1, and leaves the rest of it untouched.

  • In the argmax version the problem was that after
    voutputs_bin=torch.argmax(voutputs_bin,dim=1)
    I did not set the num_classes parameter in DiceMetric to 2, so it messed it up:
    "num_classes – number of input channels (always including the background). When this is None, y_pred.shape[1]"

This is how it works properly: (although it is not going to be 1-DiceLoss.)

voutputs_bin=torch.nn.functional.softmax(voutputs,dim=1)
voutputs_bin=vout…

Replies: 2 comments 3 replies

Comment options

You must be logged in to vote
2 replies
@franciskasara
Comment options

@KumoLiu
Comment options

Comment options

You must be logged in to vote
1 reply
@KumoLiu
Comment options

Answer selected by franciskasara
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants