InvalidArgumentError: Number of float values != expected. Values size: 3456000 but output shape: [3240]
gangooteli opened this issue · 7 comments
Hi I created tfrecords. Then i ran tried to train the model. But I am getting below error. I tried to debug the code but i am not able to do so.
Error:
INFO:tensorflow:Error reported to Coordinator: <class 'tensorflow.python.framework.errors_impl.InvalidArgumentError'>, Name: , Key: imageInput, Index: 0. Number of float values != expected. Values size: 3456000 but output shape: [3240]
[[Node: test_input/ParseExample_1/ParseExample = ParseExample[Ndense=2, Nsparse=1, Tdense=[DT_FLOAT, DT_INT64], dense_shapes=[[3240], [1]], sparse_types=[DT_INT64], _device="/job:localhost/replica:0/task:0/cpu:0"](test_input/ReaderReadUpToV2_1:1, test_input/ParseExample_1/ParseExample/names, test_input/ParseExample_1/ParseExample/sparse_keys_0, test_input/ParseExample_1/ParseExample/dense_keys_0, test_input/ParseExample_1/ParseExample/dense_keys_1, test_input/ParseExample_1/Const, test_input/ParseExample_1/Const_1)]]
Caused by op u'test_input/ParseExample_1/ParseExample', defined at:
File "train.py", line 818, in
app.run()
File "/home/nikhil/anaconda/envs/tfone/lib/python2.7/site-packages/tensorflow/python/platform/app.py", line 48, in run
_sys.exit(main(_sys.argv[:1] + flags_passthrough))
File "train.py", line 806, in main
FLAGS.export_model_steps).run(start_new_model=FLAGS.start_new_model)
File "train.py", line 435, in run
saver = self.build_model(self.model, self.reader)
File "train.py", line 699, in build_model
num_epochs=FLAGS.num_epochs)
File "train.py", line 280, in build_graph
num_epochs=num_epochs,nameT='test'))
File "train.py", line 200, in get_input_data_tensors
reader.prepare_reader(filename_queue,batch_size) for _ in range(num_readers)
File "/media/nikhil/Data/Experiments/Handwritten text Extraction/handwriting Extraction Codes/handwritten-tf-1.0-master/readers.py", line 81, in prepare_reader
return self.prepare_serialized_examples(serialized_examples)
File "/media/nikhil/Data/Experiments/Handwritten text Extraction/handwriting Extraction Codes/handwritten-tf-1.0-master/readers.py", line 114, in prepare_serialized_examples
features = tf.parse_example(serialized_examples, features=feature_map)
File "/home/nikhil/anaconda/envs/tfone/lib/python2.7/site-packages/tensorflow/python/ops/parsing_ops.py", line 563, in parse_example
dense_types, dense_defaults, dense_shapes, name)
File "/home/nikhil/anaconda/envs/tfone/lib/python2.7/site-packages/tensorflow/python/ops/parsing_ops.py", line 688, in _parse_example_raw
name=name)
File "/home/nikhil/anaconda/envs/tfone/lib/python2.7/site-packages/tensorflow/python/ops/gen_parsing_ops.py", line 178, in _parse_example
dense_shapes=dense_shapes, name=name)
File "/home/nikhil/anaconda/envs/tfone/lib/python2.7/site-packages/tensorflow/python/framework/op_def_library.py", line 768, in apply_op
op_def=op_def)
File "/home/nikhil/anaconda/envs/tfone/lib/python2.7/site-packages/tensorflow/python/framework/ops.py", line 2336, in create_op
original_op=self._default_original_op, op_def=op_def)
File "/home/nikhil/anaconda/envs/tfone/lib/python2.7/site-packages/tensorflow/python/framework/ops.py", line 1228, in init
self._traceback = _extract_stack()
InvalidArgumentError (see above for traceback): Name: , Key: imageInput, Index: 0. Number of float values != expected. Values size: 3456000 but output shape: [3240]
command to train
python train.py --slices 26 --width 12 --stride 3 --Bwidth 90 --train_data_pattern batch/tf-data-40x320-81/handwritten-test-{}.tfrecords --train_dir separable_lstm --test_data_pattern batch/tf-data-40x320-81/handwritten-test-{}.tfrecords --max_steps 6000 --batch_size 20 --beam_size 3 --input_chanels 1 --model MDLSTMCTCModel --base_learning_rate 0.001 --num_readers 2 --export_model_steps 500 --display_step 10 --display_step_lme 100 --start_new_model
Please help
@gangooteli , I met the same problem. You have any solution for this issue ?
Thank
be sure the tfrecords shape are the same as in the python command line
@gangooteli , I also met the problem, almost the same. Did you have it solved? Could you please tell me ?
@ZhanHaolan316 Sorry, I was not able to solve the problem. Then I needed to left this in between.
One thing which I can say is that it is due to mismatch in weight file i.e. tfrecords
Error:
Values size: 3456000 but output shape: [3240]
It means in model MDLSTMCTCModel output shape is [3240] but we are loading weight whose value size is 3456000
Due to this there is mismatch
@ZhanHaolan316 Sorry, I was not able to solve the problem. Then I needed to left this in between.
One thing which I can say is that it is due to mismatch in weight file i.e. tfrecords
Error:
Values size: 3456000 but output shape: [3240]It means in model MDLSTMCTCModel output shape is [3240] but we are loading weight whose value size is 3456000
Due to this there is mismatch
How can I solve the mismatch? Could you please tell me?
@gangooteli , I met the same problem. You have any solution for this issue ?
Thank
did you find a solution?
I also ran into this error, but it was really all my fault.
Some list that had a static size was being decoded by the TFRecords decoder with a fixed size parameter. When I changed the implementation for the list, and it was diverging from the fixed set size I also got this error. Check if the lists that are being written to TFRecords have the same length as is given in the TFRecords decoder command.