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
49c66406
Commit
49c66406
authored
Nov 09, 2020
by
Poorva Potdar
Committed by
A. Unique TensorFlower
Nov 09, 2020
Browse files
Internal change
PiperOrigin-RevId: 341433786
parent
dcc224c6
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
2 additions
and
2 deletions
+2
-2
official/nlp/modeling/ops/sampling_module.py
official/nlp/modeling/ops/sampling_module.py
+2
-2
No files found.
official/nlp/modeling/ops/sampling_module.py
View file @
49c66406
...
@@ -88,12 +88,12 @@ class SamplingModule(decoding_module.DecodingModule, metaclass=abc.ABCMeta):
...
@@ -88,12 +88,12 @@ class SamplingModule(decoding_module.DecodingModule, metaclass=abc.ABCMeta):
if
not
self
.
do_sample
:
if
not
self
.
do_sample
:
topk_log_probs
,
topk_ids
=
self
.
_greedy
(
probs
)
topk_log_probs
,
topk_ids
=
self
.
_greedy
(
probs
)
else
:
else
:
temperature_fn
=
SamplingModule
.
sample_logits_with_temperature
temperature_fn
=
self
.
sample_logits_with_temperature
probs
=
tf
.
cond
(
self
.
sample_temperature
>
0.0
,
probs
=
tf
.
cond
(
self
.
sample_temperature
>
0.0
,
lambda
:
temperature_fn
(
probs
,
self
.
sample_temperature
),
lambda
:
temperature_fn
(
probs
,
self
.
sample_temperature
),
lambda
:
probs
)
lambda
:
probs
)
probs
=
tf
.
cond
(
self
.
top_k
is
not
None
and
self
.
top_k
>
1
,
probs
=
tf
.
cond
(
self
.
top_k
is
not
None
and
self
.
top_k
>
1
,
lambda
:
SamplingModule
.
_sample_top_k
(
probs
,
self
.
top_k
),
lambda
:
self
.
_sample_top_k
(
probs
,
self
.
top_k
),
lambda
:
probs
)
lambda
:
probs
)
topk_ids
=
tf
.
random
.
categorical
(
probs
,
dtype
=
tf
.
int32
,
num_samples
=
1
)
topk_ids
=
tf
.
random
.
categorical
(
probs
,
dtype
=
tf
.
int32
,
num_samples
=
1
)
topk_log_probs
=
tf
.
gather
(
topk_log_probs
=
tf
.
gather
(
...
...
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