首页 > 解决方案 > TimeDistributed Convolution2D Keras 的正确输入

问题描述

我有一个 327 帧的序列,尺寸为 480 行和 640 列,灰度。

print (X_train.shape) 给出:(327, 480, 640, 1)

我有以下模型:

N = 2 #number of frames to distribute
model = Sequential()
model.add(TimeDistributed(Convolution2D(32, activation='relu'), input_shape = (N, 480,640,1)))
...

print (model.output_shape) 给出:(None, 2, 480, 640, 32)

我需要多一维才能将此输入传递给卷积。实际上我有以下错误: ValueError: Error when checks input: expected time_distributed_1_input to have 5 dimension, but got array with shape (327, 480, 640, 1)

如何解决这个问题?

谢谢!

编辑:从根本上说,我需要将输入 (327, 480, 640, 1) 转换为 (x, 2, 480, 640, 1) (x=327/2 ?)

标签: tensorflowkerasconv-neural-network

解决方案


您正在尝试对 3D 数据 (2x480x640) 执行 2D 卷积。使用Convolution3D


推荐阅读