Skip to content

Instantly share code, notes, and snippets.

@AFAgarap
Created May 16, 2019 09:31
Show Gist options
  • Save AFAgarap/659efb1a52d39c3177f596f1e323561f to your computer and use it in GitHub Desktop.
Save AFAgarap/659efb1a52d39c3177f596f1e323561f to your computer and use it in GitHub Desktop.
TensorFlow 2.0 implementation of a decoder layer for a variational autoencoder.
class Decoder(tf.keras.layers.Layer):
def __init__(self, original_dim):
super(Decoder, self).__init__()
self.hidden_layer_1 = tf.keras.layers.Dense(units=32, activation=tf.nn.relu)
self.hidden_layer_2 = tf.keras.layers.Dense(units=64, activation=tf.nn.relu)
self.hidden_layer_3 = tf.keras.layers.Dense(units=128, activation=tf.nn.relu)
self.output_layer = tf.keras.layers.Dense(units=original_dim, activation=tf.nn.sigmoid)
def call(self, input_features):
activation_1 = self.hidden_layer_1(input_features)
activation_2 = self.hidden_layer_2(activation_1)
activation_3 = self.hidden_layer_3(activation_2)
output = self.output_layer(activation_3)
return output
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment