Python 将keras后端从theano更改为tensorflow时出现类型错误
我正在尝试使用tensorflow后端。model.py中的compile_gru_model函数在更改后端时给出一个TypeErrorPython 将keras后端从theano更改为tensorflow时出现类型错误,python,tensorflow,speech-recognition,keras,Python,Tensorflow,Speech Recognition,Keras,我正在尝试使用tensorflow后端。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',
# 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.
TypeError:应为int32,而应为'Variable'类型。
即使使用K.cast()将输入转换为int32,错误仍然存在。这段代码在theano后端工作
Tensorflow版本:1.1.0
Keras版本:1.1.2
任何帮助都将不胜感激。谢谢 为了记录在案,通过升级到keras 2.0.4解决了该问题。相关问题,由Tensorflow中的API更改引起。需要降低tensorflow或升级Keras