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

multi-output logs #19159

Closed
innat opened this issue Feb 8, 2024 · 3 comments
Closed

multi-output logs #19159

innat opened this issue Feb 8, 2024 · 3 comments
Assignees
Labels
keras-team-review-pending Pending review by a Keras team member. type:support User is asking for help / asking an implementation question. Stackoverflow would be better suited.

Comments

@innat
Copy link

innat commented Feb 8, 2024

In this doc, the multi output modeling is demonstrated as follows

# Stick a logistic regression for priority prediction on top of the features
priority_pred = layers.Dense(1, name="priority")(x)
# Stick a department classifier on top of the features
department_pred = layers.Dense(num_departments, name="department")(x)

# Instantiate an end-to-end model predicting both priority and department
model = keras.Model(
    inputs=[title_input, body_input, tags_input],
    outputs={"priority": priority_pred, "department": department_pred},
)

model.compile(
    optimizer=keras.optimizers.RMSprop(1e-3),
    loss={
        "priority": keras.losses.BinaryCrossentropy(from_logits=True),
        "department": keras.losses.CategoricalCrossentropy(from_logits=True),
    },
    loss_weights={"priority": 1.0, "department": 0.2},
)

model.fit

And the log messages are below. The loss here is the total loss of the multi objective. But how to get individual objective for priority and department target? In keras 2, it gives all of them but not in keras 3.

Epoch 1/2
 40/40 ━ 1s 12ms/step - loss: 1.2673
Epoch 2/2
 40/40 ━ 0s 12ms/step - loss: 1.2440
@sachinprasadhs sachinprasadhs added type:support User is asking for help / asking an implementation question. Stackoverflow would be better suited. keras-team-review-pending Pending review by a Keras team member. labels Feb 8, 2024
@haifeng-jin
Copy link
Contributor

@innat Thanks for the issue!
We would like to keep the logs clearer with a single output loss.
It may also significantly add to the code complexity if we want to support this feature.

The user would need to add anything that they want to display separately to the metrics.

Copy link

Are you satisfied with the resolution of your issue?
Yes
No

@innat
Copy link
Author

innat commented Feb 15, 2024

very logical.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
keras-team-review-pending Pending review by a Keras team member. type:support User is asking for help / asking an implementation question. Stackoverflow would be better suited.
Projects
None yet
Development

No branches or pull requests

3 participants