This repository was archived by the owner on Jul 7, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
Fix decoding in prepend mode #1726
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
17f27db
Create an integer problem_0_steps variable.
e8cce3f
Merge branch 'master' of github.com:tensorflow/tensor2tensor
9da23d6
Merge branch 'master' of github.com:tensorflow/tensor2tensor
a2a0503
Save inputs to the feature "partial_targets" when prepend_mode is not…
b0a0a21
Removed a second call to update_hparams_for_universal_transformer().
78d36a4
Fix a bug to make partial targets work for beam size > 1
dorndorf File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -927,6 +927,13 @@ def _interactive_input_tensor_to_features_dict(feature_map, hparams): | |
features["decode_length"] = ( | ||
IMAGE_DECODE_LENGTH if input_is_image else inputs[1]) | ||
features["inputs"] = x | ||
# Save inputs to "partial_targets" when prepending inputs to targets. Also | ||
# keep "inputs" as some models crash if they don't exist. | ||
if getattr(hparams, "prepend_mode", "none") != "none": | ||
shape = tf.shape(x) | ||
partial_targets = tf.reshape(x, [shape[0], shape[1]]) | ||
partial_targets = tf.pad(partial_targets, [[0, 0], [0, 1]]) | ||
features["partial_targets"] = partial_targets | ||
return features | ||
|
||
|
||
|
@@ -957,6 +964,13 @@ def _decode_input_tensor_to_features_dict(feature_map, hparams): | |
features["decode_length"] = ( | ||
IMAGE_DECODE_LENGTH if input_is_image else tf.shape(x)[1] + 50) | ||
features["inputs"] = x | ||
# Save inputs to "partial_targets" when prepending inputs to targets. Also | ||
# keep "inputs" as some models crash if they don't exist. | ||
if getattr(hparams, "prepend_mode", "none") != "none": | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
seems more idiomatic python, here and above |
||
shape = tf.shape(x) | ||
partial_targets = tf.reshape(x, [shape[0], shape[1]]) | ||
partial_targets = tf.pad(partial_targets, [[0, 0], [0, 1]]) | ||
features["partial_targets"] = partial_targets | ||
return features | ||
|
||
|
||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @senarvi -- thanks for the PR, I'm going to be releasing on TF 1.15 really soon.
Can you "flip" the comments, i.e. make the 1.15 one main and put the other in a comment?
Also a brief explanation of why this workaround is needed would be great