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
1e0c9da9
Commit
1e0c9da9
authored
Jul 09, 2020
by
A. Unique TensorFlower
Browse files
Internal change
PiperOrigin-RevId: 320536301
parent
2e8a07d9
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
5 additions
and
5 deletions
+5
-5
official/nlp/tasks/masked_lm.py
official/nlp/tasks/masked_lm.py
+4
-4
official/nlp/tasks/sentence_prediction.py
official/nlp/tasks/sentence_prediction.py
+1
-1
No files found.
official/nlp/tasks/masked_lm.py
View file @
1e0c9da9
...
@@ -62,10 +62,10 @@ class MaskedLMTask(base_task.Task):
...
@@ -62,10 +62,10 @@ class MaskedLMTask(base_task.Task):
sentence_labels
=
labels
[
'next_sentence_labels'
]
sentence_labels
=
labels
[
'next_sentence_labels'
]
sentence_outputs
=
tf
.
cast
(
sentence_outputs
=
tf
.
cast
(
model_outputs
[
'next_sentence'
],
dtype
=
tf
.
float32
)
model_outputs
[
'next_sentence'
],
dtype
=
tf
.
float32
)
sentence_loss
=
tf
.
keras
.
losses
.
sparse_categorical_crossentropy
(
sentence_loss
=
tf
.
reduce_mean
(
sentence_labels
,
tf
.
keras
.
losses
.
sparse_categorical_crossentropy
(
sentence_labels
,
sentence_outputs
,
sentence_outputs
,
from_logits
=
True
)
from_logits
=
True
)
)
metrics
[
'next_sentence_loss'
].
update_state
(
sentence_loss
)
metrics
[
'next_sentence_loss'
].
update_state
(
sentence_loss
)
total_loss
=
mlm_loss
+
sentence_loss
total_loss
=
mlm_loss
+
sentence_loss
else
:
else
:
...
...
official/nlp/tasks/sentence_prediction.py
View file @
1e0c9da9
...
@@ -91,7 +91,7 @@ class SentencePredictionTask(base_task.Task):
...
@@ -91,7 +91,7 @@ class SentencePredictionTask(base_task.Task):
if
aux_losses
:
if
aux_losses
:
loss
+=
tf
.
add_n
(
aux_losses
)
loss
+=
tf
.
add_n
(
aux_losses
)
return
loss
return
tf
.
reduce_mean
(
loss
)
def
build_inputs
(
self
,
params
,
input_context
=
None
):
def
build_inputs
(
self
,
params
,
input_context
=
None
):
"""Returns tf.data.Dataset for sentence_prediction task."""
"""Returns tf.data.Dataset for sentence_prediction task."""
...
...
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