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

lovasz_hinge as loss function Error #27

Open
AmericaBG opened this issue Oct 31, 2019 · 1 comment
Open

lovasz_hinge as loss function Error #27

AmericaBG opened this issue Oct 31, 2019 · 1 comment

Comments

@AmericaBG
Copy link

Hi!!
Firstly, thank you very much for sharing your code. It's a great work!

I'm trying to train my model with lovasz_hinge as loss function:

model.compile(optimizer =opt,loss= [lovasz_hinge], metrics = [matthews_correlation])

But I have the next error:

File "C:\Users\Usuario\Anaconda3\envs\env_gpu\lib\site-packages\keras\optimizers.py", line 91, in get_gradients
raise ValueError('An operation has None for gradient. '

ValueError: An operation has None for gradient. Please make sure that all of your ops have a gradient defined (i.e. are differentiable). Common ops without gradient: K.argmax, K.round, K.eval

Do you know what it's the problem?

Thank you very much in advance!

@Frost-Lee
Copy link

According to this comment, simply swap the argument position of labels and logits will help.

def lovasz_hinge(labels, logits, per_image=True, ignore=None):
    # No need to change the implementation of the function

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