Skip to content

Instantly share code, notes, and snippets.

@NMZivkovic
Last active January 19, 2019 12:58
Show Gist options
  • Save NMZivkovic/5af2740b759212341eeb9308937fd4e8 to your computer and use it in GitHub Desktop.
Save NMZivkovic/5af2740b759212341eeb9308937fd4e8 to your computer and use it in GitHub Desktop.
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