Created
April 20, 2019 04:58
-
-
Save StrikingLoo/a317384f4ee3163feab0cd0c774c2d1d to your computer and use it in GitHub Desktop.
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
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) #49152 #3072 | |
x = layers.BatchNormalization()(x) | |
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.BatchNormalization()(x) | |
x = layers.Dense(translator_layer_size, activation='relu', name='decoder')(x) | |
outputs = layers.Dense(total_pixels, activation='sigmoid', 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