You could interpolate the filters first e.g. via F.interpolate(..., mode='nearest').
If you specify mode='nearest', it’ll make sure to repeat the values instead of e.g. interpolate them linearly.
Alternatively you could also use matplotlib or PIL to store the filters, which would provide an argument for the desired shape.