class Generator(object):
def __init__(self, noise_shape):
self.noise_shape = noise_shape
def generator(self):
gen_input = Input(shape = self.noise_shape)
model = Conv2D(filters = 64, kernel_size = 9, strides = 1, padding = "same")(gen_input)
model = PReLU(alpha_initializer='zeros', alpha_regularizer=None, alpha_constraint=None, shared_axes=[1,2])(model)
gen_model = model
# Using 16 Residual Blocks
for index in range(16):
model = res_block_gen(model, 3, 64, 1)
model = Conv2D(filters = 64, kernel_size = 3, strides = 1, padding = "same")(model)
model = BatchNormalization(momentum = 0.5)(model)
model = add([gen_model, model])
# Using 2 UpSampling Blocks
for index in range(2):
model = up_sampling_block(model, 3, 256, 1)
model = Conv2D(filters = 3, kernel_size = 9, strides = 1, padding = "same")(model)
model = Activation('tanh')(model)
generator_model = Model(inputs = gen_input, outputs = model)
return generator_model