Skip to content

Commit

Permalink
Use dictionaries for both loss and loss_weights consistently (ker…
Browse files Browse the repository at this point in the history
…as-team#500)

* Use dictionaries for both `loss` and `loss_weights` consistently

* Update the description text

* `python autogen.py add_guide functional_api.py`
  • Loading branch information
ronshapiro authored Jun 16, 2021
1 parent 51f6470 commit b48a9a9
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
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

0 comments on commit b48a9a9

Please sign in to comment.