For what it's worth, I've found Pytorch to be much more rigid than TF. Maybe I just haven't found the easy way to do things. For example here's a function that applies an N×N box filter to all but the first 2 dimensions of a tensor (apologies to mobile users):
def boxfilter(image, N=3):
shape = image.shape
image = tf.reshape(image, [1, shape[0], shape[1], -1])
C = image.shape[-1]
conv = tf.nn.conv2d(image, tf.eye(C, C, [N, N]), 1, "SAME")[0]
return tf.reshape(conv, shape) / (N * N)
Is there a simple way to do this in Pytorch? Preferably without having to inherit from the base class for convolution. It seems to me that Pytorch is like Keras and Tensorflow is like Numpy.