-
Notifications
You must be signed in to change notification settings - Fork 19.5k
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
K.ctc_batch_cost() get slice index 0 of dimension 0 out of bounds error when using online trainning (batch_size=1) #7049
Comments
Hi ! I am having the same problem with Keras 2.0.6 and TensorFlow 1.2.0. |
Yes. I am also having the same problem. The problem is definitely related to conversion of dense to sparse. |
Glad someone already posted this.
Here is a somewhat minimal example that shows what's happening. It only occurs for batch_size exactly equal to one. @fchollet It's fairly urgent for me, so if you have any pointers where I could look, I could aid in the investigation. I tried reading the corresponding Tensorflow source code at tensorflow-master\tensorflow\core\util\strided_slice_op.cc, line 299 but as a TF beginner, progress is pretty slow so far. |
Tried to get into TF debugging and was able to get this stack, if it helps:
|
@fchollet I think this problem can be basically solved by modifying the function ctc_batch_cost() in label_length = tf.to_int32(tf.squeeze(label_length))
input_length = tf.to_int32(tf.squeeze(input_length)) If the Hence, my basic solution is to squeeze only along axis 1, that is, label_length = tf.to_int32(tf.squeeze(label_length, axis=1))
input_length = tf.to_int32(tf.squeeze(input_length, axis=1)) It leads to the rank 1 tensors for all kinds of batch size. I try this solution on my computer, and it works well! |
You are right about the label_length. Input length is the length of the input sequences. In case of OCR it may represent the sequence of feature vectors created from the input image. |
@xisnu Input to the LSTM is (batch_size, 26, 512 ) in my case and the output is (batch_size, 26, 37 ). So what should be the input_length? |
Suppose you have three samples like this |
@saisumanth007 It should be the length of inputs before padding, and thus, it can not be determined based on the information you give. |
@xisnu @WindQAQ Suppose in OCR, I have 3 images : image1,image2 and image3 with ground truth strings "goat", "mat", "is" respectively. |
Basically, if you do not pad the inputs, that is, the feature vectors of images, the input_length should be an array filled with 26. It depends on whether you pad the inputs. Maybe you can talk about how you extract the feature vectors from images so that I can help you directly. |
Hello, I am using CTC loss function in my model, everything were good until I tried to using online training (batch_size =1). The error was caused by K.ctc_batch_cost function.
The error can be reproduced with the keras example "image_ocr.py" by simply set the "minibatch_size = 1 " in line 446 ( the parameter of TextImagegenerator).
I am using keras 2.0.2 with tensorflow 1.1.0 backend.
Thank you!
The text was updated successfully, but these errors were encountered: