1

Ich habe das folgende Modell in Keras und TimeDistributed (Flatten()) (x) funktioniert nicht, gibt es die gleiche Form wie die Ausgabe. Ich benutze die neueste Version von Keras mit Tensorflow-Backend und Python 3.5.3 unter Windows 10. Mache ich etwas falsch? Gibt es eine alternative Lösung?TimeDistributed (Flatten()) gibt die gleiche Ausgangsform in Keras

rnn_size = 128 

input_tensor = Input((width, height, 3)) 

x = input_tensor 

x = Convolution2D(32, 3, 3, activation='relu', input_shape=[width, height, 3])(x) 
x = Convolution2D(32, 3, 3, activation='relu')(x) 
x = MaxPooling2D(pool_size=(2, 2))(x) 

x = Convolution2D(32, 3, 3, activation='relu')(x) 
x = Convolution2D(32, 3, 3, activation='relu')(x) 
x = MaxPooling2D(pool_size=(2, 2))(x) 

x = Convolution2D(32, 3, 3, activation='relu')(x) 
x = Convolution2D(32, 3, 3, activation='relu')(x) 
x = MaxPooling2D(pool_size=(2, 2))(x) 

conv_shape = x.get_shape() 
x = Reshape(target_shape = (int(conv_shape [1]), int(conv_shape[2] * conv_shape[3])))(x) 

x = Dense(32, activation='relu')(x) 

x = GRU(rnn_size, return_sequences=True, init='he_normal', name='gru1')(x) 

x = TimeDistributed(Flatten())(x) 
x = TimeDistributed(Dropout(0.25))(x) 
x = TimeDistributed(Dense(n_class, init='he_normal', activation='softmax'))(x) 

model = Model(input = [input_tensor], output = [x]) 

model.compile(loss='categorical_crossentropy', optimizer='adadelta') 

Antwort

0

Die neueste Keras-Verteilung hat dies für mich funktioniert (Ubuntu 16.04). Wenn die Distribution für Win10 nicht, Keras auf die Github-Version aktualisieren.

Verwandte Themen