Skip to content

Instantly share code, notes, and snippets.

@AFAgarap
Created November 19, 2019 16:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AFAgarap/6be3896502dd7f47a0b684793a199f2d to your computer and use it in GitHub Desktop.
Save AFAgarap/6be3896502dd7f47a0b684793a199f2d to your computer and use it in GitHub Desktop.
TensorFlow 2.0 implementation of mini VGG-based decoder for an autoencoder
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