Created
May 16, 2019 09:31
-
-
Save AFAgarap/659efb1a52d39c3177f596f1e323561f to your computer and use it in GitHub Desktop.
TensorFlow 2.0 implementation of a decoder layer for a variational 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 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