Hi! Looks like a nice framework for pytorch->tflite conversion, however I face conversion issue when I try to convert depthwise convolution to keras, code below.
ValueError: Layer depthwise_conv1d weight shape (3, 32, 1) is not compatible with provided weight shape (3, 1, 32).
Reproducible example:
import torch.nn as nn
import torch
from nobuco.convert.converter import pytorch_to_keras
from nobuco.commons import ChannelOrder
class SimpleDepthwiseConvExample(nn.Module):
def __init__(self, in_channels=32, out_channels=32, kernel_size=3, stride=1, n_groups=32):
super().__init__()
self.conv = nn.Conv1d(in_channels, out_channels, kernel_size, stride, kernel_size//2, groups=n_groups)
def forward(self, x):
return self.conv(x)
if __name__ == '__main__':
bs = 1
n_channels = 32
n_groups = n_channels
# n_groups = 1
features = 144
inputs = [
torch.rand(bs, n_channels, features)
]
model = SimpleDepthwiseConvExample(
in_channels=n_channels,
out_channels=n_channels,
n_groups=n_groups
)
keras_model = pytorch_to_keras(
model, inputs, inputs_channel_order=ChannelOrder.PYTORCH
)
I think I was able to fix it in nobuco/converters/impl.py, -
change weights = weights.transpose((2, 1, 0))
to weights = weights.transpose((2, 0, 1)), after the change checker seems to pass.
Can you confirm that the error is on the side of the library?
Hi! Looks like a nice framework for pytorch->tflite conversion, however I face conversion issue when I try to convert depthwise convolution to keras, code below.
Env:
Error:
Reproducible example:
I think I was able to fix it in
nobuco/converters/impl.py
, - changeweights = weights.transpose((2, 1, 0))
toweights = weights.transpose((2, 0, 1))
, after the change checker seems to pass.Can you confirm that the error is on the side of the library?