Last active
March 3, 2021 07:10
-
-
Save f-rumblefish/6337c2d6c672b24c0e943f2df8cf1ed2 to your computer and use it in GitHub Desktop.
Autoencoder
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 keras.layers import Input, Dense, Conv2D, MaxPooling2D, UpSampling2D | |
from keras.models import Model | |
input_img = Input(shape=(28, 28, 1)) | |
x = Conv2D(32, (3, 3), activation='relu', padding='same')(input_img) | |
x = MaxPooling2D((2, 2), padding='same')(x) | |
x = Conv2D(32, (3, 3), activation='relu', padding='same')(x) | |
x = MaxPooling2D((2, 2), padding='same')(x) | |
x = Conv2D(32, (3, 3), activation='relu', padding='same')(x) | |
encoded = MaxPooling2D((2, 2), padding='same')(x) | |
x = Conv2D(32, (3, 3), activation='relu', padding='same')(encoded) | |
x = UpSampling2D((2, 2))(x) | |
x = Conv2D(32, (3, 3), activation='relu', padding='same')(x) | |
x = UpSampling2D((2, 2))(x) | |
x = Conv2D(32, (3, 3), activation='relu')(x) | |
x = UpSampling2D((2, 2))(x) | |
decoded = Conv2D(1, (3, 3), activation='sigmoid', padding='same')(x) | |
autoencoder = Model(input_img, decoded) | |
autoencoder.compile(optimizer='adam', loss='binary_crossentropy') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment