Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Decode function in decoder #179

Closed
ihungalexhsu opened this issue Nov 18, 2018 · 2 comments
Closed

Decode function in decoder #179

ihungalexhsu opened this issue Nov 18, 2018 · 2 comments

Comments

@ihungalexhsu
Copy link

In the decode function of the Decoder.py, when calculating the length, I think there are some issues. To be more specific,
update_idx = ((lengths > step) & eos_batches) != 0
lengths[update_idx] = len(sequence_symbols)
the update_idx would return [0,1,0,1,.....] sequence not the index that are nonzero
I think it should be update_idx = np.nonzero((lengths > step) & eos_batches)

Can you check this part? I'm not pretty sure that I'm correct.
Appreciate.

@pskrunner14
Copy link

Hi @ihungalexhsu I think they're actually the same operation as shown below:

>>> import numpy as np
>>> a = np.array([1, 2, 3, 4, 5, 6, 7, 8, 9, 10])
>>> b = a
>>> a
array([ 1,  2,  3,  4,  5,  6,  7,  8,  9, 10])
>>> b
array([ 1,  2,  3,  4,  5,  6,  7,  8,  9, 10])
>>> a[a > 5] = 1  # access using boolean array with same dims
>>> a
array([1, 2, 3, 4, 5, 1, 1, 1, 1, 1])
>>> b[np.array([5, 6, 7, 8, 9])] = 1  # access using indices
>>> b
array([1, 2, 3, 4, 5, 1, 1, 1, 1, 1])

At first I thought it was a bug too but the end result says otherwise.

@ihungalexhsu
Copy link
Author

Got it! Thanks for your clarify

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants