【问题标题】:CTC Beam Search using Tensorflow Backend使用 TensorFlow 后端的 CTC Beam 搜索
【发布时间】:2017-05-31 07:08:47
【问题描述】:

keras 文档和 tensorflow 提供了一个函数 ctc_decode,它对网络的输出进行 ctc 波束搜索解码。该文档没有提供解码器的示例用法。 https://github.com/igormq/ctc_tensorflow_example/blob/master/ctc_tensorflow_example.py 提供了一个示例用法,但我无法检索解码的文本转录本。

关于打印输出张量的 stackoverflow 存在问题,但我没有得到任何输出,因为我的张量的输出具有形状(?,?)。

>>> pred.shape
(1, 489, 29)
>>> dec, logp = K.ctc_decode(K.variable(pred, dtype='float32'), 
K.variable([489],dtype='int32'),greedy=False)
>>> dec
[<tf.Tensor 'SparseToDense:0' shape=(?, ?) dtype=int64>]
>>> dec[0]
<tf.Tensor 'SparseToDense:0' shape=(?, ?) dtype=int64>
>>> s = tf.Session()
>>> s.run(tf.global_variables_initializer())
>>> print dec[0].eval(session=s)
[[0]]

pred 是神经网络的输出。请帮助我了解出了什么问题,因为我认为我应该获得为预测解码的字符的数值,但我得到的是 [[0]]。

【问题讨论】:

    标签: python tensorflow speech-recognition keras beam-search


    【解决方案1】:

    如果您使用的是 Keras,请尝试 K.get_value(dec[0])

    【讨论】:

      【解决方案2】:
      dec_tf, logp_tf = K.ctc_decode(K.variable(pred, dtype='float32'), K.variable([489],dtype='int32'),greedy=False)
      dec = K.eval(dec_tf)
      logp = K.eval(logp_tf)
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2022-10-12
        • 2018-03-16
        • 1970-01-01
        • 2018-01-16
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多