Understanding basic Keras Conv2DTranspose example

Viewed 1559

This is definitely a basic question, but I'm having trouble understanding exactly what is going on with Keras's layers.Conv2DTranspose function. I have the following three lines:

Setup

model = tf.keras.Sequential()
...
model.add(layers.Reshape((10, 10, 256)))
model.add(layers.Conv2DTranspose(128, (5, 5), strides=(1, 1), padding='same', use_bias=False))
assert model.output_shape == (None, 10, 10, 128)

The first occurrence of Reshape gets me a tensor of shape [10x10x256].

In the Conv2DTranspose layer, somehow I'm sliding a filter of shape [5x5] along this tensor and ending up with a new tensor of shape [10x10x128].

Graphical depiction of what I think this is doing

Question

What mathematically is happening to get me from the first tensor [10x10x256] to the second [10x10x128]?

1 Answers

It's almost the same as a convolution, but with fancy paddings to get the feeling of doing a backward convolution.

The sliding window in your picture is correctly positioned.
But it's not a "window", it is actually a "sliding block". The size of the block is 256 in depth.

So, it goes multiplying and summing all the channels for each stride.

But then there are 128 different sliding blocks (as you defined in your layer with filters=128). Each of these 128 sliding blocks produce separate output channel.


Great explanations about transposed convolutions: https://datascience.stackexchange.com/questions/6107/what-are-deconvolutional-layers

Related