【问题标题】:TypeError on changing keras backend from theano to tensorflow将 keras 后端从 theano 更改为 tensorflow 时出现 TypeError
【发布时间】:2017-10-29 10:12:00
【问题描述】:

我正在尝试将 tensorflow 后端用于 https://github.com/baidu-research/ba-dls-deepspeech/ 。 model.py 中的 compile_gru_model 函数在更改后端时会出现 TypeError。

# Main acoustic input
acoustic_input = Input(shape=(None, input_dim), name='acoustic_input')

# Setup the network
conv_1d = Convolution1D(nodes, conv_context, name='conv1d',
                        border_mode=conv_border_mode,
                        subsample_length=conv_stride, init=initialization,
                        activation='relu')(acoustic_input)
if batch_norm:
    output = BatchNormalization(name='bn_conv_1d', mode=2)(conv_1d)
else:
    output = conv_1d

for r in range(recur_layers):
    output = GRU(nodes, activation='relu',
                 name='rnn_{}'.format(r + 1), init=initialization,
                 return_sequences=True)(output)
    if batch_norm:
        bn_layer = BatchNormalization(name='bn_rnn_{}'.format(r + 1),
                                      mode=2)
        output = bn_layer(output)

在运行 GRU 层时,报错:

TypeError: Expected int32, got <tf.Variable 'rnn_1_W_z_1:0' shape=(1024, 1024) dtype=float32_ref> of type 'Variable' instead.

即使使用 K.cast() 将输入转换为 int32,错误仍然存​​在。此代码适用于 theano 后端。

张量流版本:1.1.0
Keras 版本:1.1.2

任何帮助将不胜感激。谢谢!

【问题讨论】:

标签: python tensorflow speech-recognition keras


【解决方案1】:

作为记录,问题已通过升级到 keras 2.0.4 得到解决。

【讨论】:

    猜你喜欢
    • 2018-04-26
    • 2017-04-27
    • 2017-07-28
    • 2017-12-12
    • 2017-06-29
    • 2017-06-27
    • 2021-06-15
    • 1970-01-01
    • 2019-09-28
    相关资源
    最近更新 更多