def generator():
noise_input = Input(shape = (100,))
dense1 = Reshape((256, 256, 3))(Dense(256*256*3)(noise_input))
image_input = Input(shape=(256, 256, 3))
concat_layer_gen = Concatenate()([image_input, dense1])
# Encoder Network
conv_1 = Conv2D(64,4,strides=2,use_bias=False,kernel_initializer=RandomNormal(mean=0.,stddev=0.02),padding='same')(concat_layer_gen)
act_1 = LeakyReLU(alpha=0.2)(conv_1)
conv_2 = Conv2D(128,4,strides=2,use_bias=False,kernel_initializer=RandomNormal(mean=0.,stddev=0.02),padding='same')(act_1)
batch_norm_2 = BatchNormalization(momentum=0.8)(conv_2)
act_2 = LeakyReLU(alpha=0.2)(batch_norm_2)
conv_3 = Conv2D(256,4,strides=2,use_bias=False,kernel_initializer=RandomNormal(mean=0.,stddev=0.02),padding='same')(act_2)
batch_norm_3 = BatchNormalization(momentum=0.8)(conv_3)
act_3 = LeakyReLU(alpha=0.2)(batch_norm_3)
conv_4 = Conv2D(512,4,strides=2,use_bias=False,kernel_initializer=RandomNormal(mean=0.,stddev=0.02),padding='same')(act_3)
batch_norm_4 = BatchNormalization(momentum=0.8)(conv_4)
act_4 = LeakyReLU(alpha=0.2)(batch_norm_4)
conv_5 = Conv2D(512,4,strides=2,use_bias=False,kernel_initializer=RandomNormal(mean=0.,stddev=0.02),padding='same')(act_4)
batch_norm_5 = BatchNormalization(momentum=0.8)(conv_5)
act_5 = LeakyReLU(alpha=0.2)(batch_norm_5)
conv_6 = Conv2D(512,4,strides=2,use_bias=False,kernel_initializer=RandomNormal(mean=0.,stddev=0.02),padding='same')(act_5)
batch_norm_6 = BatchNormalization(momentum=0.8)(conv_6)
act_6 = LeakyReLU(alpha=0.2)(batch_norm_6)
conv_7 = Conv2D(512,4,strides=2,use_bias=False,kernel_initializer=RandomNormal(mean=0.,stddev=0.02),padding='same')(act_6)
batch_norm_7 = BatchNormalization()(conv_7)
act_7= LeakyReLU(alpha=0.2)(batch_norm_7)
conv_8 = Conv2D(512,4,strides=2,use_bias=False,kernel_initializer=RandomNormal(mean=0.,stddev=0.02),padding='same')(act_7)
batch_norm_8 = BatchNormalization(momentum=0.8)(conv_8)
act_8 = LeakyReLU(alpha=0.2)(batch_norm_8)
# Decoder Network and skip connections with encoder
convt_1 = Conv2DTranspose(512,4,strides=2,use_bias=False,kernel_initializer=RandomNormal(mean=0.,stddev=0.02),padding='same')(act_8)
batch_normt_1 = BatchNormalization(momentum=0.8)(convt_1)
drop_1 = Dropout(0.5)(batch_normt_1)
actt_1 = ReLU()(drop_1)
concat_1 = Concatenate()([actt_1, act_7])
convt_2 = Conv2DTranspose(512,4,strides=2,use_bias=False,kernel_initializer=RandomNormal(mean=0.,stddev=0.02),padding='same')(concat_1)
batch_normt_2 = BatchNormalization(momentum=0.8)(convt_2)
drop_2 = Dropout(0.5)(batch_normt_2)
actt_2 = ReLU()(drop_2)
concat_2 = Concatenate()([actt_2, act_6])
convt_3 = Conv2DTranspose(512,4,strides=2,use_bias=False,kernel_initializer=RandomNormal(mean=0.,stddev=0.02),padding='same')(concat_2)
batch_normt_3 = BatchNormalization(momentum=0.8)(convt_3)
drop_3 = Dropout(0.5)(batch_normt_3)
actt_3 = ReLU()(drop_3)
concat_3 = Concatenate()([actt_3, act_5])
convt_4 = Conv2DTranspose(512,4,strides=2,use_bias=False,kernel_initializer=RandomNormal(mean=0.,stddev=0.02),padding='same')(concat_3)
batch_normt_4 = BatchNormalization(momentum=0.8)(convt_4)
actt_4 = ReLU()(batch_normt_4)
concat_4 = Concatenate()([actt_4, act_4])
convt_5 = Conv2DTranspose(256,4,strides=2,use_bias=False,kernel_initializer=RandomNormal(mean=0.,stddev=0.02),padding='same')(concat_4)
batch_normt_5 = BatchNormalization(momentum=0.8)(convt_5)
actt_5 = ReLU()(batch_normt_5)
concat_5 = Concatenate()([actt_5, act_3])
convt_6 = Conv2DTranspose(128,4,strides=2,use_bias=False,kernel_initializer=RandomNormal(mean=0.,stddev=0.02),padding='same')(concat_5)
batch_normt_6 = BatchNormalization(momentum=0.8)(convt_6)
actt_6 = ReLU()(batch_normt_6)
concat_6 = Concatenate()([actt_6, act_2])
convt_7 = Conv2DTranspose(64,4,strides=2,use_bias=False,kernel_initializer=RandomNormal(mean=0.,stddev=0.02),padding='same')(concat_6)
batch_normt_7 = BatchNormalization(momentum=0.8)(convt_7)
actt_7 = ReLU()(batch_normt_7)
concat_7 = Concatenate()([actt_7, act_1])
outputs = Conv2DTranspose(3,4,strides=2,use_bias=False,activation='tanh',kernel_initializer=RandomNormal(mean=0.,stddev=0.02),padding='same')(concat_7)
gen_model = Model([noise_input, image_input], outputs)
gen_model.summary()
return gen_model