This repository was archived by the owner on Jan 1, 2021. It is now read-only.
Open
Conversation
LT;DR: length calculation is wrong, padded zeros are never ignored. Note that `vocab_encode` encodes the each char an index in `1`..`vocab_len`: that's what is stored in `seq` before it goes through one-hot encodding. It is expected that `tf.one_hot` will encode only valid indices and return zeros for paddings (which is `0`), but it's not what it does. Instead, it will encode every index in `0`..`vocab_len-1` and ignore `vocab_len`. This means that `}` char will always end the seq, while padded zeros are processed as normal chars. Doing `seq - 1` fixes both the padding `0` (should be invalid) and `vocab_len` (should be valid) indices.
Since one-hot encoding shifts the index down by 1, the generator must account for that, otherwise the sample sequence will collapse to zeros
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
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
LT;DR: length calculation is wrong, padded zeros are never ignored.
Note that
vocab_encodeencodes each char as an index in1..vocab_len: that's what is stored inseqbefore it goes through one-hot encodding. It is expected thattf.one_hotwill encode only valid indices and return zeros for paddings (which is0), but it's not what it does. Instead, it will encode every index in0..vocab_len-1and ignorevocab_len. This means that}char will always end the seq, while padded zeros are processed as normal chars.Doing
seq - 1fixes both the padding0(should be invalid) andvocab_len(should be valid) indices.By the way, length calculation can also be simplified to
tf.reduce_sum(tf.reduce_max(seq, 2), 1)