I noticed that my converted frozen .pb was much larger than a very similar model natively defined in Tensorflow. This turned out to be because of the pointwise convolution weights stored in the converted model - but these weights were all zero. I figured that instead of using a separable conv with a no-op pointwise conv, we can simply use a depthwise conv. I replaced it, and everything appears to be working as expected. tests/layers/convolutions/conv2d.py runs with a max error of 8.344650268554688e-07.
There is one caveat, which is that for whatever reason the dilation_rate parameter of keras.layers.DepthwiseConv2D isn't explicitly documented. This seems to be a documentation error rather than it being an unsupported feature, because it is most definitely used in the functional layer.
EDIT: Oh, and as a result, my .pb file went from 4.4mb to 1.3mb with the exact same output error (compared to the PyTorch model).
I noticed that my converted frozen
.pb
was much larger than a very similar model natively defined in Tensorflow. This turned out to be because of the pointwise convolution weights stored in the converted model - but these weights were all zero. I figured that instead of using a separable conv with a no-op pointwise conv, we can simply use a depthwise conv. I replaced it, and everything appears to be working as expected.tests/layers/convolutions/conv2d.py
runs with a max error of8.344650268554688e-07
.There is one caveat, which is that for whatever reason the
dilation_rate
parameter ofkeras.layers.DepthwiseConv2D
isn't explicitly documented. This seems to be a documentation error rather than it being an unsupported feature, because it is most definitely used in the functional layer.EDIT: Oh, and as a result, my
.pb
file went from 4.4mb to 1.3mb with the exact same output error (compared to the PyTorch model).