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
74438979
"vscode:/vscode.git/clone" did not exist on "d4d7af24c94995299634a6fa086f9b9ae353c1b3"
Commit
74438979
authored
Dec 09, 2020
by
Poorva Potdar
Committed by
A. Unique TensorFlower
Dec 09, 2020
Browse files
Internal change
PiperOrigin-RevId: 346570482
parent
4c6e23c8
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
5 additions
and
5 deletions
+5
-5
official/nlp/modeling/ops/sampling_module.py
official/nlp/modeling/ops/sampling_module.py
+5
-5
No files found.
official/nlp/modeling/ops/sampling_module.py
View file @
74438979
...
...
@@ -25,7 +25,7 @@ from official.nlp.modeling.ops import decoding_module
def
greedy
(
log_probs
):
"""Returns the top ids and scores based on greedy decoding."""
log_probs
,
ids
=
tf
.
nn
.
top_k
(
log_probs
,
k
=
1
)
log_probs
,
ids
=
tf
.
math
.
top_k
(
log_probs
,
k
=
1
)
return
log_probs
,
ids
...
...
@@ -56,9 +56,9 @@ def sample_top_k(logits, top_k):
Logits with top_k filtering applied.
"""
top_k_logits
=
tf
.
math
.
top_k
(
logits
,
k
=
top_k
)
indices_to_remove
=
logits
<
top_k_logits
[
0
][...,
-
1
,
None
]
top_k_logits
=
set_tensor_by_indices_to_value
(
logits
,
indices_to_remove
,
np
.
NINF
)
indices_to_remove
=
logits
<
tf
.
expand_dims
(
top_k_logits
[
0
][...,
-
1
]
,
-
1
)
top_k_logits
=
set_tensor_by_indices_to_value
(
logits
,
indices_to_remove
,
np
.
NINF
)
return
top_k_logits
...
...
@@ -425,7 +425,7 @@ class SamplingModule(decoding_module.DecodingModule, metaclass=abc.ABCMeta):
finished_cond
,
finished_seq
)
score_cond
=
decoding_module
.
expand_to_same_rank
(
finished_cond
,
finished_scores
)
finished_seq
=
tf
.
where
(
seq_cond
,
finished_seq
,
alive_seq
,
finished_scores
)
finished_seq
=
tf
.
where
(
seq_cond
,
finished_seq
,
alive_seq
)
finished_scores
=
tf
.
where
(
score_cond
,
finished_scores
,
alive_log_probs
)
return
finished_seq
,
finished_scores
...
...
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