📚 The CoCalc Library - books, templates and other resources
1import tensorflow as tf 2 3from layers import * 4 5def encoder(input): 6 # Create a conv network with 3 conv layers and 1 FC layer 7 # Conv 1: filter: [3, 3, 1], stride: [2, 2], relu 8 9 # Conv 2: filter: [3, 3, 8], stride: [2, 2], relu 10 11 # Conv 3: filter: [3, 3, 8], stride: [2, 2], relu 12 13 # FC: output_dim: 100, no non-linearity 14 raise NotImplementedError 15 16def decoder(input): 17 # Create a deconv network with 1 FC layer and 3 deconv layers 18 # FC: output dim: 128, relu 19 20 # Reshape to [batch_size, 4, 4, 8] 21 22 # Deconv 1: filter: [3, 3, 8], stride: [2, 2], relu 23 24 # Deconv 2: filter: [8, 8, 1], stride: [2, 2], padding: valid, relu 25 26 # Deconv 3: filter: [7, 7, 1], stride: [1, 1], padding: valid, sigmoid 27 raise NotImplementedError 28 29def autoencoder(input_shape): 30 # Define place holder with input shape 31 32 # Define variable scope for autoencoder 33 with tf.variable_scope('autoencoder') as scope: 34 # Pass input to encoder to obtain encoding 35 36 # Pass encoding into decoder to obtain reconstructed image 37 38 # Return input image (placeholder) and reconstructed image 39 pass 40 41