Machine learning 可以对图像序列进行图像预处理吗?

Machine learning 可以对图像序列进行图像预处理吗?,machine-learning,neural-network,keras,conv-neural-network,lstm,Machine Learning,Neural Network,Keras,Conv Neural Network,Lstm,我试图使用Keras的内置图像预处理功能来增强序列中的图像。 我的数据集具有13200个序列的形状(13200,4168168,168,1),每个序列由4个168x168px灰度图像组成 尝试在我的数据集上运行datagen.flow()时,我得到: ValueError: ('Input data in `NumpyArrayIterator` should have rank 4. You passed an array with shape', (13200, 4, 168, 168, 1

我试图使用Keras的内置图像预处理功能来增强序列中的图像。 我的数据集具有13200个序列的形状
(13200,4168168,168,1)
,每个序列由4个168x168px灰度图像组成

尝试在我的数据集上运行
datagen.flow()
时,我得到:

ValueError: ('Input data in `NumpyArrayIterator` should have rank 4. You passed an array with shape', (13200, 4, 168, 168, 1))

我假设
ImageDataGenerator
无法正确处理每个样本4张图像的序列。有没有办法做到这一点

尝试通过以下方式定义新的生成器:

def sequence_image_generator(x, y, batch_size, generator, seq_len=4):
    new_y = numpy.repeat(y, seq_len, axis = 0)
    helper_flow = generator.flow(x.reshape((x.shape[0] * seq_len,
                                            x.shape[2],
                                            x.shape[3],
                                            x.shape[4])),
                                 new_y,
                                 batch_size=seq_len * batch_size)
    for x_temp, y_temp in helper_flow:
        yield x_temp.reshape((x_temp.shape[0] / seq_len, 
                              seq_len, 
                              x.shape[2],
                              x.shape[3],
                              x.shape[4])), y_temp[::seq_len,:]

你的
y
看起来像什么?
y.shape=(13200250)
因为我有250门课。好的-所以我的答案应该是正确的。谢谢你的回答。当我运行它时,我得到:
ValueError:X(图像张量)和y(标签)应该具有相同的长度。
因此我在
numpy.repeat()中添加了
axis=0
。现在我得到了
ValueError:对于包含
yield
语句的最后一行,新数组的总大小必须保持不变。你知道这是什么原因吗?现在试试。(
y_temp[::seq_len,:]
)相同的错误。调试时,我发现实际上是第一部分(重塑
x_temp
)导致了错误。啊-好的。我忘了
图像生成器的恼人部分。现在试试。必须在
x_temp.shape[0]/seq_len
周围放置
int()
,现在它终于可以工作了。非常感谢你,马辛!