顺序层的UpSampling2D层中无法理解填充

时间:2018-12-13 12:45:00

标签: keras keras-2

我正在使用顺序keras API构建CNN模型,但是在第12行(model.add(UpSampling2D((2, 2), padding='same')))上遇到以下错误

TypeError: ('Keyword argument not understood:', 'padding')

我正在使用Keras 2.2.4和Tensorflow 1.12.0

关于为什么发生这种情况的任何想法吗?

我的代码是:

# Fit regression DNN model 
print("Creating/Training CNN")
model = Sequential()
model.add( Conv2D(16, (3, 3), input_shape=(128,128,1), activation='relu', padding = 'same') )
model.add(MaxPooling2D((2, 2), padding='same'))
model.add( Conv2D(8, (3, 3), activation='relu', padding='same') )
model.add(MaxPooling2D((2, 2), padding='same'))
model.add( Conv2D(8, (3, 3), activation='relu', padding='same') )
model.add(MaxPooling2D((2, 2), padding='same', name = 'grab_that'))

model.add( Conv2D(8, (3, 3), activation='relu', padding='same') )
model.add(UpSampling2D((2, 2), padding='same'))
model.add( Conv2D(8, (3, 3), activation='relu', padding='same') )
model.add(UpSampling2D((2, 2), padding='same'))
model.add( Conv2D(16, (3, 3), activation='relu', padding='same') )
model.add(UpSampling2D((2, 2), padding='same'))
model.add( Conv2D(1, (3, 3), activation='sigmoid', padding='same') )
model.compile(optimizer='adadelta', loss='binary_crossentropy', metrics=[binary_accuracy])
history = model.fit(data_train,data_train,verbose=1,epochs=1)

1 个答案:

答案 0 :(得分:1)

发生这种情况是因为UpSampling2D图层没有这样的参数。只有卷积层具有它(请参阅docs)。