I'm trying to build a CNN similar to this:
For this purpose I chose to use Keras since I worked with it before (simple RNN and FFNN only). My training data consists of the input data (25 x 25px images) and the output, being 25 x 25px images as well. The problem is, that I don't know how to build the Model using Keras. How do I specify the output to be of the same shape as the input?
Here is what I have so far:
batch_size = 5
input_shape = (batch_size, 28, 28, 32)
model = Sequential()
model.add(Conv2D(32, kernel_size=(5, 5), strides=(1, 1),
activation='relu',
input_shape=input_shape))
model.add(MaxPooling2D(pool_size=(2, 2), strides=(2, 2)))
model.add(Conv2D(64, (5, 5), activation='relu'))
model.add(MaxPooling2D(pool_size=(2, 2)))
model.add(Flatten())
model.add(Dense(1000, activation='relu'))
model.add(Conv2D(64, (5, 5), activation='relu'))
model.add(MaxPooling2D(pool_size=(2, 2), strides=(2, 2)))
model.add(Conv2D(32, kernel_size=(5, 5), strides=(1, 1),
activation='relu',
input_shape=input_shape))
model.compile(loss=keras.losses.categorical_crossentropy,
optimizer=keras.optimizers.SGD(lr=0.01),
metrics=['accuracy'])
I know, that the code will not work like that. I just want to clarify what I'm trying to do. The code above was taken from: Keras tutorial – build a convolutional neural network in 11 lines
As of now I just tried to reverse the code from the point, where the tutorial would output the predicted label for the given image to transform the result back to the wanted output image.