Created
July 18, 2019 19:35
-
-
Save michelkana/48027d1692d4a907911713ab8b366c70 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
import keras | |
from keras.layers import Input, Dense | |
from keras.models import Model | |
from keras.datasets import mnist | |
import numpy as np | |
# input layer | |
input_img = Input(shape=(784,)) | |
# autoencoder | |
encoding_dim = 32 | |
encoded = Dense(encoding_dim, activation='relu')(input_img) | |
encoded_input = Input(shape=(encoding_dim,)) | |
decoded = Dense(784, activation='sigmoid')(encoded) | |
autoencoder = Model(input_img, decoded) | |
decoder_layer = autoencoder.layers[-1] | |
decoder = Model(encoded_input, decoder_layer(encoded_input)) | |
autoencoder.compile(optimizer='adadelta', loss='binary_crossentropy') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment