Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
ModelZoo
ResNet50_tensorflow
Commits
c25d7711
Commit
c25d7711
authored
Feb 23, 2020
by
Hongkun Yu
Committed by
A. Unique TensorFlower
Feb 23, 2020
Browse files
tf.keras.backend.sparse_categorical_crossentropy -> tf.keras.losses.sparse_categorical_crossentropy
PiperOrigin-RevId: 296755118
parent
6f0e3a0b
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
2 additions
and
2 deletions
+2
-2
official/nlp/bert/run_squad.py
official/nlp/bert/run_squad.py
+2
-2
No files found.
official/nlp/bert/run_squad.py
View file @
c25d7711
...
@@ -109,9 +109,9 @@ def squad_loss_fn(start_positions,
...
@@ -109,9 +109,9 @@ def squad_loss_fn(start_positions,
end_logits
,
end_logits
,
loss_factor
=
1.0
):
loss_factor
=
1.0
):
"""Returns sparse categorical crossentropy for start/end logits."""
"""Returns sparse categorical crossentropy for start/end logits."""
start_loss
=
tf
.
keras
.
backend
.
sparse_categorical_crossentropy
(
start_loss
=
tf
.
keras
.
losses
.
sparse_categorical_crossentropy
(
start_positions
,
start_logits
,
from_logits
=
True
)
start_positions
,
start_logits
,
from_logits
=
True
)
end_loss
=
tf
.
keras
.
backend
.
sparse_categorical_crossentropy
(
end_loss
=
tf
.
keras
.
losses
.
sparse_categorical_crossentropy
(
end_positions
,
end_logits
,
from_logits
=
True
)
end_positions
,
end_logits
,
from_logits
=
True
)
total_loss
=
(
tf
.
reduce_mean
(
start_loss
)
+
tf
.
reduce_mean
(
end_loss
))
/
2
total_loss
=
(
tf
.
reduce_mean
(
start_loss
)
+
tf
.
reduce_mean
(
end_loss
))
/
2
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment