Last active
April 20, 2019 04:48
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
from tensorflow import keras | |
from tensorflow.keras import layers | |
total_pixels = img_size * img_size * 3 | |
translator_factor = 2 | |
translator_layer_size = int(total_pixels/translator_factor) | |
middle_factor = 2 | |
middle_layer_size = int(translator_layer_size/middle_factor) | |
inputs = keras.Input(shape=(img_size,img_size,3), name='cat_image') | |
x = layers.Flatten(name = 'flattened_cat')(inputs) #turn image to vector. | |
x = layers.Dense(translator_layer_size, activation='relu', name='encoder')(x) | |
x = layers.Dense(middle_layer_size, activation='relu', name='middle_layer')(x) | |
x = layers.Dense(translator_layer_size, activation='relu', name='decoder')(x) | |
outputs = layers.Dense(total_pixels, activation='relu', name='reconstructed_cat')(x) | |
outputs = layers.Reshape((img_size,img_size,3))(outputs) | |
model = keras.Model(inputs=inputs, outputs=outputs) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment