Skip to content

Instantly share code, notes, and snippets.

@AFAgarap
Last active November 16, 2019 18:49
Show Gist options
  • Save AFAgarap/148baa70a6dc00a348d42eb164f35dc3 to your computer and use it in GitHub Desktop.
Save AFAgarap/148baa70a6dc00a348d42eb164f35dc3 to your computer and use it in GitHub Desktop.
TensorFlow 2.0 implementation of an encoder layer for a vanilla autoencoder.
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