简体   繁体   中英

I create my LSTM Keras2 model , use AveragePooling2D, but NameError: name 'AveragePooling2D' is not defined

I want to make a model for training in time series Use Keras 2 and analysis dataset 20x6 size. What do I additionally need to import or what version of Keras is needed for this?

##enter code here
model.add(TimeDistributed(Dense(1)))
model.add(AveragePooling2D())

model.add(Flatten())

model.add(Dense(2, activation='softmax'))
model.compile(loss=categorical_crossentropy, optimizer=RMSprop(lr=.01))
model.fit(X_train, Y_train, epochs=100, batch_size=6000, verbose=1, validation_data=(X_test, Y_test))

Greeting

Did you import AveragePooling2D?

I don't think you did.

Add this on you code: import tf.keras.layers.AveragePooling2D

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM