solivr / tf-crnn

TensorFlow convolutional recurrent neural network (CRNN) for text recognition
GNU General Public License v3.0
292 stars 98 forks source link

train and print accuracy error #11

Closed WenmuZhou closed 7 years ago

WenmuZhou commented 7 years ago

I use a small dataset(train:1000,test:1000) to test the code, and I meet a error when train the mode at the last batch.the batchsize of train and evaluation is 128

W tensorflow/core/framework/op_kernel.cc:1192] Out of range: RandomShuffleQueue '_3_prepared_batch_queue/random_shuffle_queue' is closed and has insufficient elements (requested 128, current size 8)
         [[Node: prepared_batch_queue = QueueDequeueManyV2[component_types=[DT_STRING, DT_FLOAT, DT_INT32, DT_STRING], timeout_ms=-1, _device="/job:localhost/replica:0/task:0/cpu:0"](prepared_batch_queue/random_shuffle_queue, prepared_batch_queue/n)]]

and there is no any accuracy information output

if mode == tf.estimator.ModeKeys.EVAL:
        print('start to evaluation')
        with tf.name_scope('evaluation'):
            CER = tf.metrics.mean(tf.edit_distance(sparse_code_pred, tf.cast(sparse_code_target, dtype=tf.int64)), name='CER')

            # Convert label codes to decoding alphabet to compare predicted and groundtrouth words
            target_chars = table_int2str.lookup(tf.cast(sparse_code_target, tf.int64))
            target_words = get_words_from_chars(target_chars.values, seq_lengths_labels)
            accuracy = tf.metrics.accuracy(target_words, predictions_dict['words'], name='accuracy')

            eval_metric_ops = {
                               'eval/accuracy': accuracy,
                               'eval/CER': CER,
                               }
        CER = tf.Print(CER, [CER], message='-- CER : ')
        accuracy = tf.Print(accuracy, [accuracy], message='-- Accuracy : ')
        tf.summary.scalar('accuracy/val_accuracy', accuracy)
        print('end to evaluation')

image