The docs of the Conv2DTranspose layer mention dilation_rate but the call to the backend does not include dilation_rate. The backend function conv2d_transpose would not even support it.
In TensorFlow it would be a call to the separate function atrous_conv2d_transpose.
Is there something else going on in Keras that dilates the kernels, perhaps in the base class (i.e. Conv2D)?
In the following test at least the output of a Conv2DTranspose layer with dilation_rate == (2, 1) has the same shape as with dilation_rate == (1, 1).
from keras.models import Model
from keras.layers import Input, Conv2DTranspose
from keras import backend as K
import numpy as np
assert K.backend() == "tensorflow"
assert K.floatx() == "float32"
assert K.image_data_format() == 'channels_last'
kernel_size = (2, 1)
strides = (1, 1)
padding = 'valid'
input_shape = (6, 1, 1)
inp = Input(shape=input_shape)
ct_1_1 = Conv2DTranspose(1, kernel_size, strides=strides,
padding=padding, dilation_rate=(1, 1))(inp)
ct_2_1 = Conv2DTranspose(1, kernel_size, strides=strides,
padding=padding, dilation_rate=(2, 1))(inp)
model = Model(inputs=inp, outputs=[ct_1_1, ct_2_1])
model.compile(optimizer='rmsprop', loss='mse')
data_in = np.random.random((1, *input_shape))
result = model.predict(data_in)
print('data_in.shape ', data_in.shape)
print('result[0].shape', result[0].shape)
print('result[1].shape', result[1].shape)
output:
data_in.shape (1, 6, 1, 1)
result[0].shape (1, 7, 1, 1)
result[1].shape (1, 7, 1, 1)
But if I understand transposed convolution correctly, the output shapes should differ. So perhaps by accident Conv2DTranspose currently does not support dilation at all?
Small update: The issue is still relevant in Keras 2.1.1 with TensorFlow 1.4.0.
It looks like all the backends support this. This really should not be in the documentation if it isn't implemented. Can the CI be improved to check for this kind of thing?
I'll look into making a PR this weekend since this isn't getting any attention.
Most helpful comment
It looks like all the backends support this. This really should not be in the documentation if it isn't implemented. Can the CI be improved to check for this kind of thing?
I'll look into making a PR this weekend since this isn't getting any attention.