def create_model(self, height=32, width=32, channels=3, load_weights=False, batch_size=128):
# Perform check that model input shape is divisible by 4
init = super(DeepDenoiseSR, self).create_model(height, width, channels, load_weights, batch_size)
c1 = Convolution2D(self.n1, 3, 3, activation='relu', border_mode='same')(init)
c1 = Convolution2D(self.n1, 3, 3, activation='relu', border_mode='same')(c1)
x = MaxPooling2D((2, 2))(c1)
c2 = Convolution2D(self.n2, 3, 3, activation='relu', border_mode='same')(x)
c2 = Convolution2D(self.n2, 3, 3, activation='relu', border_mode='same')(c2)
x = MaxPooling2D((2, 2))(c2)
c3 = Convolution2D(self.n3, 3, 3, activation='relu', border_mode='same')(x)
x = UpSampling2D()(c3)
c2_2 = Convolution2D(self.n2, 3, 3, activation='relu', border_mode='same')(x)
c2_2 = Convolution2D(self.n2, 3, 3, activation='relu', border_mode='same')(c2_2)
m1 = merge([c2, c2_2], mode='sum')
m1 = UpSampling2D()(m1)
c1_2 = Convolution2D(self.n1, 3, 3, activation='relu', border_mode='same')(m1)
c1_2 = Convolution2D(self.n1, 3, 3, activation='relu', border_mode='same')(c1_2)
m2 = merge([c1, c1_2], mode='sum')
decoded = Convolution2D(channels, 5, 5, activation='linear', border_mode='same')(m2)
model = Model(init, decoded)
adam = optimizers.Adam(lr=1e-3)
model.compile(optimizer=adam, loss='mse', metrics=[PSNRLoss])
if load_weights: model.load_weights(self.weight_path)
self.model = model
return model
评论列表
文章目录