Automatic_Speech_Recognition icon indicating copy to clipboard operation
Automatic_Speech_Recognition copied to clipboard

deeepSpeech2 model ValueError: Shape must be rank 4 but is rank 3 for 'Conv2D' (op: 'Conv2D') with input shapes:

Open witkeyshare opened this issue 7 years ago • 4 comments

Traceback (most recent call last): File "main/timit_train.py", line 255, in runner.run() File "main/timit_train.py", line 144, in run model = model_fn(args, maxTimeSteps) File "/mnt/Automatic_Speech_Recognition-master/models/deepSpeech2.py", line 120, in init self.build_graph(args, maxTimeSteps) File "/mnt/Automatic_Speech_Recognition-master/utils/utils.py", line 32, in wrapper result = func(*args, **kwargs) File "/mnt/Automatic_Speech_Recognition-master/models/deepSpeech2.py", line 149, in build_graph output_fc = build_deepSpeech2(self.args, maxTimeSteps, self.inputX, self.cell_fn, self.seqLengths) File "/mnt/Automatic_Speech_Recognition-master/models/deepSpeech2.py", line 58, in build_deepSpeech2 layer1 = tf.nn.conv2d(inputX, layer1_filter, layer1_stride, padding='SAME') File "/usr/lib/python2.7/site-packages/tensorflow/python/ops/gen_nn_ops.py", line 403, in conv2d data_format=data_format, name=name) File "/usr/lib/python2.7/site-packages/tensorflow/python/framework/op_def_library.py", line 768, in apply_op op_def=op_def) File "/usr/lib/python2.7/site-packages/tensorflow/python/framework/ops.py", line 2338, in create_op set_shapes_for_outputs(ret) File "/usr/lib/python2.7/site-packages/tensorflow/python/framework/ops.py", line 1719, in set_shapes_for_outputs shapes = shape_func(op) File "/usr/lib/python2.7/site-packages/tensorflow/python/framework/ops.py", line 1669, in call_with_requiring return call_cpp_shape_fn(op, require_shape_fn=True) File "/usr/lib/python2.7/site-packages/tensorflow/python/framework/common_shapes.py", line 610, in call_cpp_shape_fn debug_python_shape_fn, require_shape_fn) File "/usr/lib/python2.7/site-packages/tensorflow/python/framework/common_shapes.py", line 676, in _call_cpp_shape_fn_impl raise ValueError(err.message) ValueError: Shape must be rank 4 but is rank 3 for 'Conv2D' (op: 'Conv2D') with input shapes: [778,32,39], [41,11,1,32].

need to preprocess data?

witkeyshare avatar Nov 07 '17 14:11 witkeyshare

@witkeyshare hi,thank you, I will fix it .

zzw922cn avatar Dec 14 '17 08:12 zzw922cn

I got the same error. ValueError: Shape must be rank 4 but is rank 3 for 'Conv2D' (op: 'Conv2D') with input shapes: [757,100,39], [41,11,1,32].

Entonytang avatar Dec 27 '17 15:12 Entonytang

The probelm is that before calling build_deepSpeech2(), there should be a reshape function called. And indeed, the author wrote the reshape line, which is in deepspeech2.py line 132:

  • self.inputXrs = tf.reshape(self.inputX, [args.batch_size, args.num_feature, maxTimeSteps, 1])

So the input of build_deepSpeech2() should be self.inputXrs, instead of self.Input in line 151 deepspeech2.py

  • output_fc = build_deepSpeech2(self.args, maxTimeSteps, self.inputXrs, self.cell_fn, self.seqLengths)

change these two lines like before, this problem should be solved. @Entonytang

Mrxiaoyuer avatar Mar 06 '18 20:03 Mrxiaoyuer

But in the deepspeech2 model, the transition from conv layer to rnn layer is not working, which is in this issue: https://github.com/zzw922cn/Automatic_Speech_Recognition/issues/49. Can anyone help with this?

Mrxiaoyuer avatar Mar 06 '18 20:03 Mrxiaoyuer