Skip to content
This repository has been archived by the owner on Jul 18, 2022. It is now read-only.

Dice Score calculation #9

Open
varghesealex90 opened this issue Apr 5, 2017 · 2 comments
Open

Dice Score calculation #9

varghesealex90 opened this issue Apr 5, 2017 · 2 comments

Comments

@varghesealex90
Copy link

Hi
Could you please point me how you calculate the dice score?

@shubhamjain0594
Copy link
Contributor

shubhamjain0594 commented Apr 5, 2017

Hi @varghesealex90

You can find the code here.

@varghesealex90
Copy link
Author

Hello Shubham;

Thank you for the prompt reply and pointing me to the code. However I do have doubt regarding the same. For the sake of simplicity, lets say 1) The output from U-net is a 3x3 label image.
dice_score =0
u_net_output = torch.ones(4,3,3) :fill(2) ---[ batches, W, H] say the label associated was 2
targets = torch.ones(4,3,3) :fill(2) --- targets are also 2, ideally dice score should be 1
for i =1 , u_net_output :size(1) do
local output = u_net_output [i]
local target = targets [i]
numerator = torch.cmul(output,target)

dice_score= dice_score + 2*(numerator:sum())/(target:sum()+output:sum())
end
dice_coeff= dice_score/u_net_output:size(1)

print (dice_coeff) yields answer =2 .

Is this because I am calculating the dice score of batch ? Any thoughts?

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

No branches or pull requests

2 participants