gmalivenko / onnx2keras

Convert ONNX model graph to Keras model format.
MIT License
193 stars 114 forks source link

About Slice Layer #35

Open weiyichang opened 4 years ago

weiyichang commented 4 years ago

Hello,

I have a problem related to slice layer .

My model is like this (I want to slice the ch dimension, and then concatenate them, i.e., I set axis attribute as 1 in slice layer in an onnx file)

截圖 2019-12-04 下午3 36 40

I add a slice layer after the first conv layer but while converting this model to tflite model, it will show that the input of concat layer is mismatch

I print the shape of slice layer like this:

截圖 2019-12-04 下午3 35 10

For the upper part, it is normal (slice input to two tensors with 4 channels and 12 channels),

but for lower part, it slices the wrong dimension

I use the setting of change_ordering=True with onnx2keras==0.0.17

Do you have any suggestion ? Thanks a lot :)

krtbb commented 4 years ago

Hello.

I encountered a same issue, and the cause seems to be in tf.nn.strided_slice() according to my test. I fixed it and you can refer to the PR #55 . (In my repository forked from here, I changed onnx2keras/reshape_layers.py/convert_slice()) Best regards.