subho406 / TF-Speech-Recognition-Challenge-Solution

Source code of the model used in Tensorflow Speech Recognition Challenge (https://www.kaggle.com/c/tensorflow-speech-recognition-challenge). The solution ranked in top 5% in private leaderboard.
GNU General Public License v3.0
58 stars 28 forks source link

error in input shape when call freeze.freeze #12

Open halbaqshi opened 4 years ago

halbaqshi commented 4 years ago

after I complete the training and call freeze.freeze I got this error:

File "/home/hussain/anaconda3/lib/python3.5/site-packages/tensorflow/python/framework/common_shapes.py", line 686, in _call_cpp_shape_fn_impl input_tensors_as_shapes, status) File "/home/hussain/anaconda3/lib/python3.5/site-packages/tensorflow/python/framework/errors_impl.py", line 473, in exit c_api.TF_GetCode(self.status.status)) tensorflow.python.framework.errors_impl.InvalidArgumentError: Shape must be rank 1 but is rank 0 for 'Reshape' (op: 'Reshape') with input shapes: [?,1], [].

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "", line 151, in File "/home/hussain/anaconda3/lib/python3.5/site-packages/tensorflow/python/platform/app.py", line 48, in run _sys.exit(main(_sys.argv[:1] + flags_passthrough)) File "", line 146, in main File "../libs/classification/freeze.py", line 163, in freeze_graph FLAGS.dct_coefficient_count, model_architecture,model_size_info) File "../libs/classification/freeze.py", line 73, in create_inference_graph decoded_sample_data=tf.reshape(decoded_sample_data,shape=(model_settings['desired_samples'])) File "/home/hussain/anaconda3/lib/python3.5/site-packages/tensorflow/python/ops/gen_array_ops.py", line 3938, in reshape "Reshape", tensor=tensor, shape=shape, name=name) File "/home/hussain/anaconda3/lib/python3.5/site-packages/tensorflow/python/framework/op_def_library.py", line 787, in _apply_op_helper op_def=op_def) File "/home/hussain/anaconda3/lib/python3.5/site-packages/tensorflow/python/framework/ops.py", line 2958, in create_op set_shapes_for_outputs(ret) File "/home/hussain/anaconda3/lib/python3.5/site-packages/tensorflow/python/framework/ops.py", line 2209, in set_shapes_for_outputs shapes = shape_func(op) File "/home/hussain/anaconda3/lib/python3.5/site-packages/tensorflow/python/framework/ops.py", line 2159, in call_with_requiring return call_cpp_shape_fn(op, require_shape_fn=True) File "/home/hussain/anaconda3/lib/python3.5/site-packages/tensorflow/python/framework/common_shapes.py", line 627, in call_cpp_shape_fn require_shape_fn) File "/home/hussain/anaconda3/lib/python3.5/site-packages/tensorflow/python/framework/common_shapes.py", line 691, in _call_cpp_shape_fn_impl raise ValueError(err.message) ValueError: Shape must be rank 1 but is rank 0 for 'Reshape' (op: 'Reshape') with input shapes: [?,1], [].

halbaqshi commented 4 years ago

I tried to modify the codes and variables. I got other error like below

save_checkpoint='../logs&checkpoint/Conv/ckpt-15300.index'

model_architecture='conv' save_path=os.path.join(FLAGS.models_dir,model_architecture,'%s.pb'%os.path.basename(save_checkpoint)) freeze.freeze_graph(FLAGS,model_architecture,save_checkpoint,save_path) Traceback (most recent call last): File "", line 1, in File "/home/hussain/Downloads/TF-Speech-Recognition-Challenge-Solution-master/libs/classification/freeze.py", line 150, in freeze_graph

Create an output to use for inference.

File "/home/hussain/Downloads/TF-Speech-Recognition-Challenge-Solution-master/libs/classification/models.py", line 143, in load_variables_from_checkpoint saver = tf.train.Saver(tf.global_variables()) File "/home/hussain/anaconda3/lib/python3.5/site-packages/tensorflow/python/training/saver.py", line 1218, in init self.build() File "/home/hussain/anaconda3/lib/python3.5/site-packages/tensorflow/python/training/saver.py", line 1227, in build self._build(self._filename, build_save=True, build_restore=True) File "/home/hussain/anaconda3/lib/python3.5/site-packages/tensorflow/python/training/saver.py", line 1251, in _build raise ValueError("No variables to save") ValueError: No variables to save

halbaqshi commented 4 years ago

I fixed the previos error by changing the

decoded_sample_data=tf.reshape(decoded_sample_data,[shape=(model_settings['desired_samples']))

to

decoded_sample_data=tf.reshape(decoded_sample_data,[shape=(1600,1))
halbaqshi commented 4 years ago

also sometime I got this error

Traceback (most recent call last): File "", line 1, in File "/home/hussain/Downloads/TF-Speech-10words/libs/classification/freeze.py", line 165, in freeze_graph FLAGS.dct_coefficient_count, model_architecture,model_size_info) File "/home/hussain/Downloads/TF-Speech-10words/libs/classification/freeze.py", line 83, in create_inference_graph decoded_sample_data.sample_rate, AttributeError: 'Tensor' object has no attribute 'sample_rate'

if I changed decoded_sample_data to

decoded_sample_data=tf.reshape(decoded_sample_data,shape=([model_settings['desired_samples'],1]))