Last active
November 16, 2019 18:49
-
-
Save AFAgarap/148baa70a6dc00a348d42eb164f35dc3 to your computer and use it in GitHub Desktop.
TensorFlow 2.0 implementation of an encoder layer for a vanilla autoencoder.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Encoder(tf.keras.layers.Layer): | |
def __init__(self, intermediate_dim): | |
super(Encoder, self).__init__() | |
self.hidden_layer = tf.keras.layers.Dense( | |
units=intermediate_dim, | |
activation=tf.nn.relu, | |
kernel_initializer='he_uniform' | |
) | |
self.output_layer = tf.keras.layers.Dense( | |
units=intermediate_dim, | |
activation=tf.nn.sigmoid | |
) | |
def call(self, input_features): | |
activation = self.hidden_layer(input_features) | |
return self.output_layer(activation) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment