text_plain_output_1.png
from keras.layers import Input, Dropout, Dense, Conv2D, MaxPooling2D, UpSampling2D

from keras.layers.noise import GaussianNoise, GaussianDropout

from keras.layers.normalization import BatchNormalization

from keras.models import Model

from keras.regularizers import l1,l2,l1_l2

from keras.models import Model
from keras.layers import Input, Dropout, Dense, Conv2D, MaxPooling2D, UpSampling2D
from keras.preprocessing.image import ImageDataGenerator
from keras.callbacks import LearningRateScheduler
from keras.layers.normalization import BatchNormalization
from keras.layers.noise import GaussianNoise, GaussianDropout
from keras.regularizers import l1, l2, l1_l2
from keras import optimizers
kernel_reg = 1e-07
activity_reg = 1e-07
input_image = Input(shape=(64, 64, 3), name='input_image')
x = Conv2D(32, (3, 3), activation='relu', padding='valid', name='encoder_conv1')(input_image)
x = MaxPooling2D((2, 2), padding='same', name='encoder_pool1')(x)
x = BatchNormalization(name='batchnorm_2')(x)
x = Conv2D(128, (3, 3), activation='relu', padding='valid', name='encoder_conv2')(x)
x = MaxPooling2D((2, 2), padding='same', name='encoder_pool2')(x)
x = BatchNormalization(name='batchnorm_3')(x)
x = Conv2D(512, (3, 3), activation='relu', padding='valid', kernel_regularizer=l2(kernel_reg), name='encoder_conv3')(x)
x = MaxPooling2D((2, 2), padding='same', name='encoder_pool3')(x)
x = BatchNormalization(name='batchnorm_4')(x)
x = Conv2D(1024, (3, 3), activation='relu', padding='valid', kernel_regularizer=l2(kernel_reg), name='encoder_conv4')(x)
x = MaxPooling2D((2, 2), padding='same', name='encoder_pool4')(x)
x = BatchNormalization(name='batchnorm_5')(x)
x = Conv2D(2048, (3, 3), activation='relu', padding='valid', kernel_regularizer=l2(kernel_reg), name='encoder_conv5')(x)
x = MaxPooling2D((3, 3), padding='same', name='encoder_pool5')(x)
x = BatchNormalization(name='batchnorm_6')(x)
image_representation = Conv2D(2048, (1, 1), activation='relu', kernel_regularizer=l2(kernel_reg), activity_regularizer=l1(activity_reg), name='encoder_fc6')(x)
image_representation = GaussianDropout(rate=0.1)(image_representation)
image_representation = GaussianNoise(stddev=0.1)(image_representation)
encoder = Model(input_image, image_representation, name='encoder')
external_image_representation = Input(shape=(1, 1, 2048), name='extenral_image_rep')
x = UpSampling2D((5, 5))(external_image_representation)
x = BatchNormalization(name='decoder_BN_1')(x)
x = Conv2D(512, (3, 3), activation='relu', padding='valid', kernel_regularizer=l2(kernel_reg), name='decoder_conv1')(x)
x = UpSampling2D((3, 3), interpolation='bilinear')(x)
x = BatchNormalization(name='decoder_BN_2')(x)
x = Conv2D(256, (3, 3), activation='relu', padding='same', kernel_regularizer=l2(kernel_reg), name='decoder_conv2')(x)
x = UpSampling2D((2, 2), interpolation='bilinear')(x)
x = BatchNormalization(name='decoder_BN_3')(x)
x = Conv2D(256, (3, 3), activation='relu', padding='valid', kernel_regularizer=l2(kernel_reg), name='decoder_conv3')(x)
x = UpSampling2D((2, 2), interpolation='bilinear')(x)
x = BatchNormalization(name='decoder_BN_4')(x)
x = Conv2D(128, (3, 3), activation='relu', padding='same', kernel_regularizer=l2(kernel_reg), name='decoder_conv4')(x)
x = UpSampling2D((2, 2), interpolation='bilinear')(x)
x = BatchNormalization(name='decoder_BN_5')(x)
x = Conv2D(128, (3, 3), activation='relu', padding='same', kernel_regularizer=l2(kernel_reg), name='decoder_conv5')(x)
output_image = Conv2D(3, (3, 3), activation='linear', padding='same', name='generated_image')(x)
decoder = Model(external_image_representation, output_image, name='decoder')
autoencoder = Model(input_image, decoder(encoder(input_image)))
autoencoder.summary()