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

support for dictionary-type loss functions without explicitly declaring None #20243

Open
WJiang0123 opened this issue Sep 9, 2024 · 1 comment
Assignees
Labels
stat:contributions welcome A pull request to fix this issue would be welcome. type:feature The user is asking for a new feature.

Comments

@WJiang0123
Copy link

In previous versions of Keras, when providing a loss function as a dictionary for models with multiple outputs, the compileLoss function would automatically assign a default value for outputs without a defined loss. The relevant code was:

                if name in loss:
                    if loss[name]:
                        flat_losses.append(get_loss(loss[name], yt, yp))
                    else:
                        flat_losses.append(None)
                else:
                    flat_losses.append(None)

However, in the latest version, flat_losses is now simply:
flat_losses = tree.flatten(loss)
Is there a way to reintroduce support for dictionary-type loss functions without explicitly declaring None for undefined losses? This change reduces flexibility in using dictionary-based loss definitions.

@fchollet
Copy link
Member

fchollet commented Sep 9, 2024

Thanks, this is a reasonable ask. Would you be able to open a PR for the change?

@sachinprasadhs sachinprasadhs added stat:contributions welcome A pull request to fix this issue would be welcome. type:feature The user is asking for a new feature. labels Sep 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stat:contributions welcome A pull request to fix this issue would be welcome. type:feature The user is asking for a new feature.
Projects
None yet
Development

No branches or pull requests

3 participants