Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

error in input shape when call freeze.freeze #12

Open
halbaqshi opened this issue Dec 5, 2019 · 3 comments
Open

error in input shape when call freeze.freeze #12

halbaqshi opened this issue Dec 5, 2019 · 3 comments

Comments

@halbaqshi
Copy link

halbaqshi commented Dec 5, 2019

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 halbaqshi changed the title Tensorflow old version has been removed and your code not working on v2. 0 error in input shape when call freeze.freeze Dec 5, 2019
@halbaqshi
Copy link
Author

halbaqshi commented Dec 14, 2019

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
Copy link
Author

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
Copy link
Author

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]))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant