GrayScaleHY / asr_cn_tf1

自动语音识别模型,包括cnn+ctc模型和gru+ctc模型。使用tensorflow1.+和keras进行模型训练。实现中文语音识别。
2 stars 1 forks source link

ValueError: Dimension 1 in both shapes must be equal, but are 18 and 12. Shapes are [256,18] and [256,12]. for 'Assign_62' (op: 'Assign') with input shapes: [256,18], [256,12]. #1

Open albertyou2 opened 3 years ago

albertyou2 commented 3 years ago

您好 @GrayScaleHY 我用你的库跑起来训练了也成功的得到了模型 但是我在测试的时候却出现了错误,: Traceback (most recent call last): File "test_am_cnn.py", line 27, in am.ctc_model.load_weights(cmd_args.model_file) File "/Users/youyin/.local/lib/python3.6/site-packages/keras/engine/network.py", line 1166, in load_weights f, self.layers, reshape=reshape) File "/Users/youyin/.local/lib/python3.6/site-packages/keras/engine/saving.py", line 1058, in load_weights_from_hdf5_group K.batch_set_value(weight_value_tuples) File "/Users/youyin/.local/lib/python3.6/site-packages/keras/backend/tensorflow_backend.py", line 2465, in batch_set_value assign_op = x.assign(assign_placeholder) File "/Users/youyin/anaconda3/lib/python3.6/site-packages/tensorflow_core/python/ops/variables.py", line 2067, in assign self._variable, value, use_locking=use_locking, name=name) File "/Users/youyin/anaconda3/lib/python3.6/site-packages/tensorflow_core/python/ops/state_ops.py", line 227, in assign validate_shape=validate_shape) File "/Users/youyin/anaconda3/lib/python3.6/site-packages/tensorflow_core/python/ops/gen_state_ops.py", line 66, in assign use_locking=use_locking, name=name) File "/Users/youyin/anaconda3/lib/python3.6/site-packages/tensorflow_core/python/framework/op_def_library.py", line 794, in _apply_op_helper op_def=op_def) File "/Users/youyin/anaconda3/lib/python3.6/site-packages/tensorflow_core/python/util/deprecation.py", line 507, in new_func return func(*args, **kwargs) File "/Users/youyin/anaconda3/lib/python3.6/site-packages/tensorflow_core/python/framework/ops.py", line 3357, in create_op attrs, op_def, compute_device) File "/Users/youyin/anaconda3/lib/python3.6/site-packages/tensorflow_core/python/framework/ops.py", line 3426, in _create_op_internal op_def=op_def) File "/Users/youyin/anaconda3/lib/python3.6/site-packages/tensorflow_core/python/framework/ops.py", line 1770, in init control_input_ops) File "/Users/youyin/anaconda3/lib/python3.6/site-packages/tensorflow_core/python/framework/ops.py", line 1610, in _create_c_op raise ValueError(str(e)) ValueError: Dimension 1 in both shapes must be equal, but are 18 and 12. Shapes are [256,18] and [256,12]. for 'Assign_62' (op: 'Assign') with input shapes: [256,18], [256,12].

5个样本训练的,内容是是 四川话版本的 0到 10 是一个数字,望不灵赐教,感激不尽! 是否要根据标签类别数更改某些地方?

siuze commented 3 years ago

我也在测试时遇到了此类问题 ValueError: Dimension 1 in both shapes must be equal, but are 18 and 1867. Shapes are [512,18] and [512,1867]. for 'Assign_24' (op: 'Assign') with input shapes: [512,18], [512,1867]. 仅对作者的项目改动了wav.scp 和text,使用自己的数据集 格式形如:

text文件: utt_20210701_0433 a53 wieng213 gung55 nau55 cie55 utt_20210701_0499 cia55 lung53 utt_20210706_0949 siu55 liek5

wav.scp文件: utt_20210629_0001 /home/ieksiuze/waves/train/HeRong//utt_20210629_0001.wav utt_20210629_0002 /home/ieksiuze/waves/train/HeRong//utt_20210629_0002.wav

请求帮助。

siuze commented 3 years ago

将test_am.py的参数--vocab_file改为save_models/10-04-02-54-31-logs/vocab后上述错误消失,但是在执行代码段result = am.model.predict(x, steps=1)时报错: ValueError: Error when checking input: expected the_inputs to have shape (None, 32, 1) but got array with shape (32, 35, 1)