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

Add pixelwise loss weight? #13

Open
tlnagy opened this issue Oct 30, 2020 · 3 comments
Open

Add pixelwise loss weight? #13

tlnagy opened this issue Oct 30, 2020 · 3 comments

Comments

@tlnagy
Copy link

tlnagy commented Oct 30, 2020

In the original implementation, they used a weighted loss function to weight up border pixels so that the network learns those preferentially (see Fig 3D below).

image

Do you have any suggestions for how to implement this in UNet.jl? I'm still really new to Flux so sorry if this is obvious. My guess would be to implement it in loss()

UNet.jl/src/utils.jl

Lines 49 to 52 in 954c89e

function loss(x, y)
op = clamp.(u(x), 0.001f0, 1.f0)
mean(bce(op, y))
end

EDIT: Here's an implementation of the pixel-wise weights for Keras: https://jaidevd.github.io/posts/weighted-loss-functions-for-instance-segmentation/

@DhairyaLGandhi
Copy link
Owner

Could we try with a translation first? I am not familiar with their implementation, but seems to be a combination of masking and weighting. Shouldn't be too difficult at all.

@tlnagy
Copy link
Author

tlnagy commented Apr 1, 2021

What do you mean by a translation first?

@DhairyaLGandhi
Copy link
Owner

I meant translating the loss from keras, sorry I should've been clearer.

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

2 participants