def modeling(self):
input_img = Input(shape=(1, 28, 28))
# set-1
x = Convolution2D(16, 3, 3, activation='relu',
border_mode='same')(input_img) # 16,28,28
x = MaxPooling2D((2, 2), border_mode='same')(x) # 16,14,14
x = Dropout(0.25)(x) # Use dropout after maxpolling
# set-2
x = Convolution2D(8, 3, 3, activation='relu',
border_mode='same')(x) # 8,14,14
x = MaxPooling2D((2, 2), border_mode='same')(x) # 8,7,7
x = Dropout(0.25)(x) # Use dropout after maxpolling
# set-3
x = Convolution2D(8, 3, 3, activation='relu',
border_mode='same')(x) # 8,7,7
encoded = x
x = Convolution2D(8, 3, 3, activation='relu',
border_mode='same')(encoded) # 8,7,7
# x = Dropout(0.25)(x) # Use dropout after maxpolling
x = UpSampling2D((2, 2))(x) # 8,14,14
x = Convolution2D(8, 3, 3, activation='relu',
border_mode='same')(x) # 8,14,14
# x = Dropout(0.25)(x) # Use dropout after maxpolling
x = UpSampling2D((2, 2))(x) # 8, 28, 28
x = Convolution2D(16, 3, 3, activation='relu',
border_mode='same')(x) # 16, 28, 28
# x = Dropout(0.25)(x) # Use dropout after maxpolling
decoded = Convolution2D(
1, 3, 3, activation='sigmoid', border_mode='same')(x) # 1, 28, 28
autoencoder = Model(input_img, decoded)
autoencoder.compile(optimizer='adadelta', loss='binary_crossentropy')
self.autoencoder = autoencoder
评论列表
文章目录