Created
February 11, 2018 02:47
-
-
Save whenyd/7f2a58aa8b93446a1bd7b140c0937f04 to your computer and use it in GitHub Desktop.
Up-resolution using transposed convolution.
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.models import Model | |
from keras.layers import Input, Conv2D, MaxPooling2D, Conv2DTranspose | |
input_img = Input(shape=(224, 224, 3)) | |
x = Conv2D(16, (3, 3), padding='same', activation='relu')(input_img) | |
x = MaxPooling2D((2, 2))(x) | |
x = MaxPooling2D((2, 2))(x) | |
x_8x = MaxPooling2D((2, 2))(x) | |
x_16x = MaxPooling2D((2, 2))(x_8x) | |
x_32x = MaxPooling2D((2, 2))(x_16x) | |
# I think the last two layers are not necessary. | |
# x_32x = Conv2D(16, (7, 7), activation='relu')(x_32x) | |
# x_32x = Conv2D(16, (1, 1), activation='relu')(x_32x) | |
# It should be reshaped to 7x7. | |
up_32x = Conv2DTranspose(1, (64, 64), strides=32, padding='same')(x_32x) | |
model = Model(input_img, up_32x) | |
print(model.output_shape) | |
# >>> (None, 224, 224, 1) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment