尝试在Keras模型中运行光束搜索,我得到了混乱(和冲突?)错误消息。我的模型输入了诸如
inputs = Input(name='spectrograms',
shape=(None, hparams["n_spectrogram"]))
input_length = Input(name='len_spectrograms',
shape=[1], dtype='int64')
和CTC损失函数要求输入和标签长度为[1]
形状。据我了解,输出应该使用类似的
# Stick connectionist temporal classification on the end of the core model
paths = K.function(
[inputs, input_length],
K.ctc_decode(output, input_length, greedy=False, top_paths=4)[0])
但按原样,这导致对input_length
ValueError: Shape must be rank 1 but is rank 2 for 'CTCBeamSearchDecoder' (op: 'CTCBeamSearchDecoder') with input shapes: [?,?,44], [?,1].
但是如果我砍掉那个尺寸
K.ctc_decode(output, input_length[..., 0], greedy=False, top_paths=4)[0])
模型定义运行,但是当我用y = paths([x, numpy.array([[30], [30]])])
运行x.shape == (2, 30, 513)
时,我突然得到了
tensorflow.python.framework.errors_impl.InvalidArgumentError: sequence_length is not a vector
[[{{node CTCBeamSearchDecoder}} = CTCBeamSearchDecoder[beam_width=100, merge_repeated=true, top_paths=4, _device="/job:localhost/replica:0/task:0/device:CPU:0"](Log, ToInt32)]]
我在做什么错了?