Skip to content

Use dictionaries for both loss and loss_weights consistently #500

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

Merged
merged 3 commits into from
Jun 16, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions guides/functional_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,7 @@ def get_model():

"""
Since the output layers have different names, you could also specify
the loss like this:
the losses and loss weights with the corresponding layer names:
"""

model.compile(
Expand All @@ -390,7 +390,7 @@ def get_model():
"priority": keras.losses.BinaryCrossentropy(from_logits=True),
"department": keras.losses.CategoricalCrossentropy(from_logits=True),
},
loss_weights=[1.0, 0.2],
loss_weights={"priority": 1.0, "department": 0.2},
)

"""
Expand Down
4 changes: 2 additions & 2 deletions guides/ipynb/functional_api.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -681,7 +681,7 @@
},
"source": [
"Since the output layers have different names, you could also specify\n",
"the loss like this:"
"the losses and loss weights with the corresponding layer names:"
]
},
{
Expand All @@ -698,7 +698,7 @@
" \"priority\": keras.losses.BinaryCrossentropy(from_logits=True),\n",
" \"department\": keras.losses.CategoricalCrossentropy(from_logits=True),\n",
" },\n",
" loss_weights=[1.0, 0.2],\n",
" loss_weights={\"priority\": 1.0, \"department\": 0.2},\n",
")"
]
},
Expand Down
4 changes: 2 additions & 2 deletions guides/md/functional_api.md
Original file line number Diff line number Diff line change
Expand Up @@ -605,7 +605,7 @@ model.compile(
```

Since the output layers have different names, you could also specify
the loss like this:
the losses and loss weights with the corresponding layer names:


```python
Expand All @@ -615,7 +615,7 @@ model.compile(
"priority": keras.losses.BinaryCrossentropy(from_logits=True),
"department": keras.losses.CategoricalCrossentropy(from_logits=True),
},
loss_weights=[1.0, 0.2],
loss_weights={"priority": 1.0, "department": 0.2},
)
```

Expand Down