After further investigating the problem I have found the answer:
U-net generators' up-sampling stage consists of two steps:
- Use
UpSampling2D
layer
- Apply convolution on the output
The UpSampling2D
layer is in the keras documentation described as:
Repeats the rows and columns of the data by size[0] and size[1] respectively.
From this information, we can calculate the time cost for UpSampling2D
alone. Lets set size to (2,2)
, as is set in basic configuration of the U-net generator. The output of the UpSampling2D
is then doubled. In case we started with (4,4,3)
, where the last index corresponds to number of channels, the output shape will be 8,8,3
. We can see that each row and column need to be copied twice in each channel. From this we can define time complexity of a single up-sampling as:
$$
O\left(2 \cdot c \cdot n \cdot s\right)
$$
Where c corresponds to number of channels, n corresponds to input length (one side of a matrix) and s is equal to filter size. Assuming that length and filter size have square shape, the complexity is multiplied by 2. Since in this case the the filter size is known, equal to (2,2)
, the notation can be simplified to:
$$
O\left(4 \cdot c \cdot n \right) = O\left(c \cdot n \right)
$$
In my case, with only 1 channel, the complexity is simply
$$
O\left(n \right)
$$
Which means the up-sampling stage is linear, and the only important feature is input size, which is negligible to the complexity of the following convolutional layer and can be ignored.
UpSampling2d
layer in keras according to it's documentation:Repeats the rows and columns of the data by size[0] and size[1] respectively.
thus performs a linear function, which is followed by convolution $\endgroup$