【发布时间】:2019-03-11 05:46:08
【问题描述】:
我正在构建一个用于图像分类的 cnn_rnn 网络。在我的 jupyter notebook 中运行以下 python 代码时出现错误。
# model
model1 = Sequential()
# first convolutional layer
model1.add(Conv2D(32, kernel_size=(3, 3),activation='relu',input_shape(160, 120, 3)))
# second convolutional layer
model1.add(Conv2D(64, kernel_size=(3, 3), activation='relu'))
#Adding a pooling Layer
model1.add(MaxPooling2D(pool_size=(3, 3)))
#Adding dropouts
model1.add(Dropout(0.25))
# flatten and put a fully connected layer
model1.add(Flatten())
model1.add(Dense(32, activation='relu')) # fully connected
#Adding RNN N/W
model1.add(LSTM(32, return_sequences=True))
model1.add(TimeDistributed(Dense(5, activation='softmax')))
我还尝试将 input_shape=(160, 120, 3) 作为参数添加到 LSTM 函数,但无济于事。请帮忙!
P.S:我也尝试使用 GRU 而不是 LSTM,但得到了同样的错误。
更新:请注意 model.summary() 结果 enter image description here
【问题讨论】:
标签: python lstm recurrent-neural-network