Skip to content

Instantly share code, notes, and snippets.

Last active January 19, 2019 12:58
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
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')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment