Skip to content
This repository has been archived by the owner on Nov 17, 2023. It is now read-only.

The example/warpctc/ocr_predict.py has a bug, it does not provide init_states values and run the ocr_predict.py several times and will get different results. #5047

Closed
lji72 opened this issue Feb 17, 2017 · 4 comments

Comments

@lji72
Copy link

lji72 commented Feb 17, 2017

For bugs or installation issues, please provide the following information.
The more information you provide, the more likely people will be able to help you.

Environment info

Operating System:ubuntu

Compiler: gcc

Package used (Python/R/Scala/Julia):

MXNet version:

Or if installed from source:

MXNet commit hash (git rev-parse HEAD):

If you are using python package, please provide

Python version and distribution:

If you are using R package, please provide

R sessionInfo():

Error Message:

Please paste the full error message, including stack trace.

Minimum reproducible example

if you are using your own code, please provide a short script that reproduces the error.

Steps to reproduce

or if you are running standard examples, please provide the commands you have run that lead to the error.

1.Run the predict.py several time and get different results.
2.It does not provide init_states values for the lstm .
3.

What have you tried to solve it?

1.The init_states values should be provided.
2.first, init_states could be a var of class.
little changes in def __init_ocr(self):
self.init_states = init_c + init_h
all_shapes = [('data', (batch_size, 41 * 64))] + self.init_states + [('label', (batch_size, num_label))]
#print (all_shapes)
3. Provide the init_state values
#init_state_arrays = [mx.nd.zeros(x[1]) for x in self.init_states]
init_state_arrays = np.zeros((batch_size, num_hidden), dtype="float32")
init_state_dict={}
for x in self.init_states:
init_state_dict[x[0]] = init_state_arrays
self.predictor.forward(data= img1, **init_state_dict)

@xinghedyc
Copy link

I think I have the similar problem with a cnn-lstm-ctc task when using predict API to infer the results after training. The accuracy does not match when using the same dataset and checkpoint in and training.

@lji72
Copy link
Author

lji72 commented Feb 22, 2017

@xinghedyc To solve it, you just provide the init_states values which are zeros.

@xinghedyc
Copy link

@lji72 Thank you so much, it works!

@phunterlau
Copy link
Contributor

This issue is closed due to lack of activity in the last 90 days. Feel free to reopen if this is still an active issue. Thanks!

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

No branches or pull requests

3 participants