Mandatory plug: do consider using PyTorch instead. It's far easier to pick up and work with. Easy things are easy, hard things are possible.
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.https://pytorch.org/docs/master/nn.functional.html#conv2d
Torch doesn't have "same" padding, so you have to manually calculate the correct padding value for your input/output shapes.
1. PyTorch C++ API which can trivially load and execute your models exported via JIT
2. ONNX export and inference in TensorRT (highest performance inference option)
3. Or just deploy straight up PyTorch Python code - it'll run fine in "production".
One place where PyTorch is weaker than TF is mobile. TFLite is a lot more mature and has all sorts of acceleration support (GPU, DSP). So if that's what you need, at this point there's really no other good choice IMO.