Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
def _build_encoder_model(self):
print("Building Encoder...")
encoder_input = Input(shape=self.img_shape)
encoder_sequence = Flatten()(encoder_input)
encoder_sequence = Dense(512)(encoder_sequence)
encoder_sequence = LeakyReLU(alpha=0.2)(encoder_sequence)
encoder_sequence = Dense(512)(encoder_sequence)
encoder_sequence = LeakyReLU(alpha=0.2)(encoder_sequence)
mean = Dense(self.latent_dimension)(encoder_sequence)
deviation = Dense(self.latent_dimension)(encoder_sequence)
latent_vector = merge([mean, deviation],
mode=lambda p: p[0] + K.random_normal(K.shape(p[0])) * K.exp(p[1] / 2),
output_shape=lambda p: p[0])
self.encoder_model = Model(encoder_input, latent_vector, name = 'encoder')
self.encoder_model.summary()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment