Issue 1:
I'm learning the usage of keras and thinking these lines are duplicated thus could be deleted safely.

line 63-68 in https://github.com/fchollet/keras/blob/master/examples/cifar10_resnet.py

# Input image dimensions. <- FROM HERE
# We assume data format "channels_last".
img_rows = x_train.shape[1]
img_cols = x_train.shape[2]
channels = x_train.shape[3] <- TO HERE

if K.image_data_format() == 'channels_first':
img_rows = x_train.shape[2]
img_cols = x_train.shape[3]
channels = x_train.shape[1]
x_train = x_train.reshape(x_train.shape[0], channels, img_rows, img_cols)
x_test = x_test.reshape(x_test.shape[0], channels, img_rows, img_cols)
input_shape = (channels, img_rows, img_cols)
else:
img_rows = x_train.shape[1]
img_cols = x_train.shape[2]
channels = x_train.shape[3]
x_train = x_train.reshape(x_train.shape[0], img_rows, img_cols, channels)
x_test = x_test.reshape(x_test.shape[0], img_rows, img_cols, channels)
input_shape = (img_rows, img_cols, channels)

Maybe I will open a pull request soon.

Please make sure that the boxes below are checked before you submit your issue. If your issue is an implementation question, please ask your question on StackOverflow or join the Keras Slack channel and ask there instead of filing a GitHub issue.

Thank you!

Check that you are up-to-date with the master branch of Keras. You can update with:

pip install git+git://github.com/fchollet/keras.git --upgrade --no-deps

If running on TensorFlow, check that you are up-to-date with the latest version. The installation instructions can be found here.

If running on Theano, check that you are up-to-date with the master branch of Theano. You can update with:

pip install git+git://github.com/Theano/Theano.git --upgrade --no-deps

Provide a link to a GitHub Gist of a Python script that can reproduce your issue (or just copy the script here if it is short).

Issue 2:
I am using ctc_decode for unsegmented text recognition. When greedy=True, ctc_decode works as expected. But if greedy=False, the function merges repeated classes in the output sequence (for example, ABCCD becomes ABCD).

Depending on the greedy flag ctc_decode calls either tf.nn.ctc_greedy_decoder or tf.nn.ctc_beam_search_decoder. Both of them has parameter merge_repeated, which is True by default. But the meaning of this parameter is different for these functions.

For ctc_greedy_decoder:

If `merge_repeated` is `True`, merge repeated classes in output.
This means that if consecutive logits' maximum indices are the same,
only the first of these is emitted. The sequence `A B B * B * B` (where '*'
is the blank label) becomes

* `A B B B` if `merge_repeated=True`.
* `A B B B B` if `merge_repeated=False`.

For ctc_beam_search_decoder:

If `merge_repeated` is `True`, merge repeated classes in the output beams.
This means that if consecutive entries in a beam are the same,
only the first of these is emitted. That is, when the top path
is `A B B B B`, the return value is:

* `A B` if `merge_repeated = True`.
* `A B B B B` if `merge_repeated = False`.

So, for ctc_greedy_decoder, merge_repeated works with logits, and for ctc_beam_search_decoder, merge_repeated works with the result (decoded) sequence.

I tried to set merge_repeated=False in ctc_decode when ctc_beam_search_decoder is called, and ctc_decode returned expected result (consistent with the case when greedy=True):

if greedy:
(decoded, log_prob) = ctc.ctc_greedy_decoder(
inputs=y_pred, sequence_length=input_length)
else:
(decoded, log_prob) = ctc.ctc_beam_search_decoder(
inputs=y_pred,
sequence_length=input_length,
beam_width=beam_width,
top_paths=top_paths,
merge_repeated=False)