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
e30aa7d8
Commit
e30aa7d8
authored
Jun 29, 2020
by
Hongkun Yu
Committed by
A. Unique TensorFlower
Jun 29, 2020
Browse files
Internal change
PiperOrigin-RevId: 318935091
parent
cc5a7980
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
7 deletions
+8
-7
official/nlp/tasks/sentence_prediction.py
official/nlp/tasks/sentence_prediction.py
+8
-7
No files found.
official/nlp/tasks/sentence_prediction.py
View file @
e30aa7d8
...
...
@@ -125,25 +125,26 @@ class SentencePredictionTask(base_task.Task):
outputs
=
self
.
inference_step
(
features
,
model
)
loss
=
self
.
build_losses
(
labels
=
labels
,
model_outputs
=
outputs
,
aux_losses
=
model
.
losses
)
logs
=
{
self
.
loss
:
loss
}
if
self
.
metric_type
==
'matthews_corrcoef'
:
return
{
self
.
loss
:
loss
,
logs
.
update
({
'sentence_prediction'
:
tf
.
expand_dims
(
tf
.
math
.
argmax
(
outputs
[
'sentence_prediction'
],
axis
=
1
),
axis
=
0
),
'labels'
:
labels
,
}
}
)
if
self
.
metric_type
==
'pearson_spearman_corr'
:
return
{
self
.
loss
:
loss
,
logs
.
update
({
'sentence_prediction'
:
outputs
[
'sentence_prediction'
],
'labels'
:
labels
,
}
})
return
logs
def
aggregate_logs
(
self
,
state
=
None
,
step_outputs
=
None
):
if
self
.
metric_type
==
'accuracy'
:
return
None
if
state
is
None
:
state
=
{
'sentence_prediction'
:
[],
'labels'
:
[]}
state
[
'sentence_prediction'
].
append
(
...
...
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