卷积递归自动编码器Keras,预期5维,得到具有4维错误的数组

时间:2018-10-27 16:48:09

标签: python tensorflow keras keras-layer autoencoder

我正在尝试构建卷积递归自动编码器,如第5页上的本文所示。用于图像降噪。输入的是具有RGB的1080 x 1920帧。

https://research.nvidia.com/sites/default/files/publications/dnn_denoise_author.pdf][1]

我有一些问题。 当运行下面的代码时,我得到一个错误: 预期input_1的尺寸为5,但数组的形状为(2,1080,1920,3) 第一个是帧数,第二个和第三个是尺寸,第四个是通道。第五个元素是什么?

我正在使用生成器来解析数据:

train_datagen = ImageDataGenerator(
        rescale=1./255,
        )

generator_train = train_datagen.flow_from_directory(
        train_data_dir,
        target_size=(1080,1920), 
        batch_size=batch_size,
        class_mode=classification_type,
        shuffle=True)

autoencoder.fit_generator(generator_train, epochs=1, steps_per_epoch=number_samples_train//batch_size, shuffle=True,
                validation_data=generator_validation, verbose=1)

我如何添加带有发电机的第五项?

模型如下

input_img = Input(shape=(None,1080,1920,3))  

a = ConvLSTM2D(32, (3, 3), activation='relu', padding='same', return_sequences=True)(input_img)
a = ConvLSTM2D(32, (3, 3), activation='relu', padding='same', return_sequences=True )(a)

b = MaxPooling3D((2,2,2), padding='same')(a)


c = ConvLSTM2D(32, (3, 3), activation='relu', padding='same', return_sequences=True)(b)
c = ConvLSTM2D(32, (3, 3), activation='relu', padding='same',return_sequences=True)(c)

encoded = MaxPooling3D((2,2,2), padding='same')(c)




d = ConvLSTM2D(32, (3, 3), activation='relu', padding='same',return_sequences=True )(encoded)
d = ConvLSTM2D(32, (3, 3), activation='relu', padding='same', return_sequences=True)(d)

e= UpSampling3D((2, 2,2))(d)

#Skip connection
merge_one = concatenate([b, e])


f = ConvLSTM2D(32, (3, 3), activation='relu', padding='same', return_sequences=True) (merge_one)#(e)
f = ConvLSTM2D(32, (3, 3), activation='relu', padding='same', return_sequences=True) (f)#(e)

g = UpSampling3D((2, 2,2))(f)    
decoded = Conv3D(3, (3, 3, 3), activation='sigmoid', padding='same')(g)# (merge_two)

autoencoder = Model(input_img, decoded)
autoencoder.compile(optimizer='adadelta', loss='binary_crossentropy')

0 个答案:

没有答案