Created
November 19, 2019 16:03
-
-
Save AFAgarap/6be3896502dd7f47a0b684793a199f2d to your computer and use it in GitHub Desktop.
TensorFlow 2.0 implementation of mini VGG-based decoder for an autoencoder
This file contains hidden or 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, **kwargs): | |
super(Decoder, self).__init__() | |
self.convt_1_layer_1 = tf.keras.layers.Conv2DTranspose( | |
filters=64, | |
kernel_size=(3, 3), | |
activation=tf.nn.relu | |
) | |
self.convt_1_layer_2 = tf.keras.layers.Conv2DTranspose( | |
filters=64, | |
kernel_size=(3, 3), | |
activation=tf.nn.relu | |
) | |
self.convt_2_layer_1 = tf.keras.layers.Conv2DTranspose( | |
filters=32, | |
kernel_size=(3, 3), | |
activation=tf.nn.relu | |
) | |
self.convt_2_layer_2 = tf.keras.layers.Conv2DTranspose( | |
filters=1, | |
kernel_size=(3, 3), | |
strides=(1, 1), | |
activation=tf.nn.sigmoid | |
) | |
def call(self, features): | |
activation = self.convt_1_layer_1(features) | |
activation = self.convt_1_layer_2(activation) | |
activation = self.convt_2_layer_1(activation) | |
output = self.convt_2_layer_2(activation) | |
return output |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment