【问题标题】:CNN LSTM video classificationCNN LSTM 视频分类
【发布时间】:2021-06-22 08:19:51
【问题描述】:

我正在尝试创建 vgg+lstm 网络。 在这段代码中 seq_len 是 1400。

video = Input(shape=(seq_len, 224, 224,3))
cnn_base = VGG16(input_shape=(224, 224, 3), weights = 'imagenet', include_top=False)
cnn_out = GlobalAveragePooling2D()(cnn_base.output)
cnn = Model(cnn_base.input, cnn_out)
cnn.trainable=False

encoded_frames = TimeDistributed(cnn)(video)
encoded_sequence = LSTM(256)(encoded_frames)
hidden_layer = Dense(1024, activation='relu')(encoded_sequence)
outputs = Dense(1)(hidden_layer)
model = Model(video, outputs)
print(model.summary())

history = model.fit(w_train, y_train, epochs=60, batch_size=50, shuffle=True, validation_split=0.2, verbose=10)
print(history.history.keys())

我的错误是这样的:

ValueError: Input 0 is incompatible with layer model_6: expected shape=(None, 1400, 224, 224, 3), found shape=(None, 224, 224, 3)

谁能帮我解决?

【问题讨论】:

标签: keras neural-network python-3.7


【解决方案1】:

去掉输入形状中的 seq_len,因为它会生成一个 shape=(None, seq_len, 224, 224,3) 的 5 维数组。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-08-27
    • 2021-07-15
    • 1970-01-01
    • 2019-01-03
    • 2019-01-05
    • 2020-07-22
    相关资源
    最近更新 更多