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
0f5bdd0e
"tests/vscode:/vscode.git/clone" did not exist on "b63c956860373ef169cfb24c2088a9b173a72bfd"
Commit
0f5bdd0e
authored
Dec 12, 2019
by
Chen Chen
Committed by
A. Unique TensorFlower
Dec 12, 2019
Browse files
Internal change
PiperOrigin-RevId: 285285388
parent
143d09bc
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
2 deletions
+7
-2
official/transformer/v2/transformer_main.py
official/transformer/v2/transformer_main.py
+7
-2
No files found.
official/transformer/v2/transformer_main.py
View file @
0f5bdd0e
...
@@ -365,7 +365,12 @@ class TransformerTask(object):
...
@@ -365,7 +365,12 @@ class TransformerTask(object):
def
eval
(
self
):
def
eval
(
self
):
"""Evaluates the model."""
"""Evaluates the model."""
with
distribution_utils
.
get_strategy_scope
(
self
.
distribution_strategy
):
distribution_strategy
=
self
.
distribution_strategy
if
self
.
use_tpu
else
None
# We only want to create the model under DS scope for TPU case.
# When 'distribution_strategy' is None, a no-op DummyContextManager will
# be used.
with
distribution_utils
.
get_strategy_scope
(
distribution_strategy
):
if
not
self
.
predict_model
:
if
not
self
.
predict_model
:
self
.
predict_model
=
transformer
.
create_model
(
self
.
params
,
False
)
self
.
predict_model
=
transformer
.
create_model
(
self
.
params
,
False
)
self
.
_load_weights_if_possible
(
self
.
_load_weights_if_possible
(
...
@@ -375,7 +380,7 @@ class TransformerTask(object):
...
@@ -375,7 +380,7 @@ class TransformerTask(object):
return
evaluate_and_log_bleu
(
return
evaluate_and_log_bleu
(
self
.
predict_model
,
self
.
params
,
self
.
flags_obj
.
bleu_source
,
self
.
predict_model
,
self
.
params
,
self
.
flags_obj
.
bleu_source
,
self
.
flags_obj
.
bleu_ref
,
self
.
flags_obj
.
vocab_file
,
self
.
flags_obj
.
bleu_ref
,
self
.
flags_obj
.
vocab_file
,
self
.
distribution_strategy
if
self
.
use_tpu
else
None
)
distribution_strategy
)
def
predict
(
self
):
def
predict
(
self
):
"""Predicts result from the model."""
"""Predicts result from the model."""
...
...
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