Use DepthwiseConv2D rather than SeparableConv2D with no-op pointwise conv #68
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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).