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

why decoding starts from 3rd position? #4

Open
soldierofhell opened this issue Dec 26, 2018 · 3 comments
Open

why decoding starts from 3rd position? #4

soldierofhell opened this issue Dec 26, 2018 · 3 comments

Comments

@soldierofhell
Copy link

Hi,

I wonder what is the theoretical basis for starting decoding from 3rd position. I'm referring to this line:
ctc_decode = bknd.ctc_decode(y_pred[:, 2:, :], input_length=np.ones(shape[0])*shape[1])[0][0]

In image_ocr.py example on keras github there's a comment:

# the 2 is critical here since the first couple outputs of the RNN
# tend to be garbage:

But why? And why everyone is using 2 regardless of dataset, image width and text length?

@soldierofhell
Copy link
Author

Just noticed the same comment in your code :)

@soldierofhell
Copy link
Author

If I start decoding with zero I indeed receive "garbage" sometimes (usually a duplicate of first character), but if the same slicing is is in the cost function then it's not suprising

@sbillburg
Copy link
Owner

Hi,

I wonder what is the theoretical basis for starting decoding from 3rd position. I'm referring to this line:
ctc_decode = bknd.ctc_decode(y_pred[:, 2:, :], input_length=np.ones(shape[0])*shape[1])[0][0]

In image_ocr.py example on keras github there's a comment:

# the 2 is critical here since the first couple outputs of the RNN
# tend to be garbage:

But why? And why everyone is using 2 regardless of dataset, image width and text length?

To be honest, I don't know the specific reason for this, either.

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