application_vnd.jupyter.stderr_output_2.png text_plain_output_1.png
from tensorflow.keras import backend

from tensorflow.keras.layers import Activation

from tensorflow.keras.layers import Conv2D

from tensorflow.keras.models import Sequential

from tensorflow.keras.optimizers import Adam

from tensorflow.keras.utils import plot_model

INPUTS_DB = '../input/ukbench100-patches-for-sr-hdf5/output/inputs.hdf5'
OUTPUTS_DB = '../input/ukbench100-patches-for-sr-hdf5/output/outputs.hdf5'
MODEL_PATH = 'output/srcnn.model'
PLOT_PATH = 'output/plot.png'
BATCH_SIZE = 128
NUM_EPOCHS = 10
SCALE = 2.0
INPUT_DIM = 33
LABEL_SIZE = 21
PAD = int((INPUT_DIM - LABEL_SIZE) / 2.0)
STRIDE = 14

from tensorflow.keras.models import Sequential
from tensorflow.keras.layers import Conv2D
from tensorflow.keras.layers import Activation
from tensorflow.keras import backend
class SRCNN:
    @staticmethod
    def build(width, height, depth):
        model = Sequential()
        input_shape = (height, width, depth)
        if backend.image_data_format() == 'channels_first':
            input_shape = (depth, height, width)
        model.add(Conv2D(64, (9, 9), kernel_initializer='he_normal', input_shape=input_shape))
        model.add(Activation('relu'))
        model.add(Conv2D(32, (1, 1), kernel_initializer='he_normal'))
        model.add(Activation('relu'))
        model.add(Conv2D(depth, (5, 5), kernel_initializer='he_normal'))
        model.add(Activation('relu'))
        return model

from tensorflow.keras.utils import plot_model
model = SRCNN.build(33, 33, 3)

opt = Adam(learning_rate=0.001, decay=0.001 / NUM_EPOCHS)
model = SRCNN.build(width=INPUT_DIM, height=INPUT_DIM, depth=3)
model.compile(loss='mse', optimizer=opt)

print('[INFO] serializing model...')
model.save(MODEL_PATH, overwrite=True)