da03 / Attention-OCR

Visual Attention based OCR
MIT License
1.11k stars 362 forks source link

train_demo.sh throws ValueError exception #39

Closed Belval closed 7 years ago

Belval commented 7 years ago

pip3 freeze:

(Maybe I don't have the right version of Keras?)

The error thrown:

2017-05-23 10:03:59,609 root INFO loading data 2017-05-23 10:03:59,611 root INFO phase: train 2017-05-23 10:03:59,611 root INFO model_dir: model_01_16 2017-05-23 10:03:59,611 root INFO load_model: False 2017-05-23 10:03:59,611 root INFO output_dir: results 2017-05-23 10:03:59,612 root INFO steps_per_checkpoint: 2000 2017-05-23 10:03:59,612 root INFO batch_size: 64 2017-05-23 10:03:59,612 root INFO num_epoch: 3 2017-05-23 10:03:59,612 root INFO learning_rate: 1 2017-05-23 10:03:59,612 root INFO reg_val: 0 2017-05-23 10:03:59,612 root INFO max_gradient_norm: 5.000000 2017-05-23 10:03:59,613 root INFO clip_gradients: True 2017-05-23 10:03:59,613 root INFO valid_target_length inf 2017-05-23 10:03:59,613 root INFO target_vocab_size: 39 2017-05-23 10:03:59,613 root INFO target_embedding_size: 10.000000 2017-05-23 10:03:59,613 root INFO attn_num_hidden: 256 2017-05-23 10:03:59,614 root INFO attn_num_layers: 2 2017-05-23 10:03:59,614 root INFO visualize: True 2017-05-23 10:03:59,614 root INFO buckets 2017-05-23 10:03:59,614 root INFO [(16, 11), (27, 17), (35, 19), (64, 22), (80, 32)] 2017-05-23 10:03:59,614 root INFO ues GRU in the decoder. input_tensor dim: (?, 1, 32, ?) CNN outdim before squeeze: (?, 1, ?, 512) CNN outdim: (?, ?, 512) using GRU CELL in decoder Traceback (most recent call last): File "src/launcher.py", line 146, in main(sys.argv[1:], exp_config.ExpConfig) File "src/launcher.py", line 142, in main session = sess) File "/home/kankroc/AttentionOCR/Attention-OCR/src/model/model.py", line 151, in init use_gru = use_gru) File "/home/kankroc/AttentionOCR/Attention-OCR/src/model/seq2seq_model.py", line 141, in init softmax_loss_function=softmax_loss_function) File "/home/kankroc/AttentionOCR/Attention-OCR/src/model/seq2seq.py", line 993, in model_with_buckets decoder_inputs[:int(bucket[1])], int(bucket[0])) File "/home/kankroc/AttentionOCR/Attention-OCR/src/model/seq2seq_model.py", line 140, in self.target_weights, buckets, lambda x, y, z: seq2seq_f(x, y, z, False), File "/home/kankroc/AttentionOCR/Attention-OCR/src/model/seq2seq_model.py", line 122, in seq2seq_f attn_num_hidden = attn_num_hidden) File "/home/kankroc/AttentionOCR/Attention-OCR/src/model/seq2seq.py", line 675, in embedding_attention_decoder initial_state_attention=initial_state_attention, attn_num_hidden=attn_num_hidden) File "/home/kankroc/AttentionOCR/Attention-OCR/src/model/seq2seq.py", line 577, in attention_decoder cell_output, state = cell(x, state) File "/home/kankroc/AttentionOCR/env/lib/python3.5/site-packages/tensorflow/contrib/rnn/python/ops/core_rnn_cell_impl.py", line 953, in call cur_inp, new_state = cell(cur_inp, cur_state) File "/home/kankroc/AttentionOCR/env/lib/python3.5/site-packages/tensorflow/contrib/rnn/python/ops/core_rnn_cell_impl.py", line 146, in call with _checked_scope(self, scope or "gru_cell", reuse=self._reuse): File "/usr/lib/python3.5/contextlib.py", line 59, in enter return next(self.gen) File "/home/kankroc/AttentionOCR/env/lib/python3.5/site-packages/tensorflow/contrib/rnn/python/ops/core_rnn_cell_impl.py", line 77, in _checked_scope type(cell).name)) ValueError: Attempt to reuse RNNCell <tensorflow.contrib.rnn.python.ops.core_rnn_cell_impl.GRUCell object at 0x7f9a3c88cf98> with a different variable scope than its first use. First use of cell was with scope 'embedding_attention_decoder/attention_decoder/multi_rnn_cell/cell_0/gru_cell', this attempt is with scope 'embedding_attention_decoder/attention_decoder/multi_rnn_cell/cell_1/gru_cell'. Please create a new instance of the cell if you would like it to use a different set of weights. If before you were using: MultiRNNCell([GRUCell(...)] * numlayers), change to: MultiRNNCell([GRUCell(...) for in range(num_layers)]). If before you were using the same cell instance as both the forward and reverse cell of a bidirectional RNN, simply create two instances (one for forward, one for reverse). In May 2017, we will start transitioning this cell's behavior to use existing stored weights, if any, when it is called with scope=None (which can lead to silent model degradation, so this error will remain until then.)

The error seems to indicate a version mismatch, what is the recommanded combo (TF + Keras) version?

Belval commented 7 years ago

TensorFlow 1.0 with Keras 1.* did the trick.