2017-05-29 52 views
1

我正在嘗試爲https://github.com/baidu-research/ba-dls-deepspeech/使用tensorflow後端。 model.py中的compile_gru_model函數在更改後端時提供了TypeError。關於將keras後端從theano轉換爲tensorflow的類型錯誤

# 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後端工作。

Tensorflow版本:1.1.0
Keras版本:1.1.2

任何幫助,將不勝感激。謝謝!

+0

相關https://stackoverflow.com/questions/41813665/tensorflow-slim-typeerror-expected-int32-got-list-containing-tensors-of-type,由Tensorflow中的API更改引起。需要張量降級或Keras升級 –

回答

1

爲了記錄,升級到keras 2.0.4後問題得到了解決。

相關問題