AxisCommunications / onnx-to-keras

Convert onnx models exported from pytorch to tensorflow keras models with focus on performace and highleve compatibility.
MIT License
25 stars 13 forks source link

TypeError: op_maxpool() got an unexpected keyword argument 'ceil_mode' #3

Closed aitikgupta closed 4 years ago

aitikgupta commented 4 years ago

Here's a MaxPool layer (from an onnx) with following attributes:

{'ceil_mode': 0, 'kernel_shape': (3, 3), 'pads': (1, 1, 1, 1), 'strides': (2, 2)}

Here's the traceback:

Traceback (most recent call last):
  File "onnx2keras.py", line 460, in <module>
    main()
  File "onnx2keras.py", line 452, in main
    model = onnx2keras(onnx.load(infile))
  File "onnx2keras.py", line 440, in onnx2keras
    output_tensors = ops.make_op(node.op_type, inputs, attrs)
  File "onnx2keras.py", line 25, in make_op
    return getattr(self, 'op_' + op_type.lower())(*inputs, **attrs)
TypeError: op_maxpool() got an unexpected keyword argument 'ceil_mode'

Is this a TF1.x vs TF2.x issue, if not, could you provide more insights?

hakanardo commented 4 years ago

Don't know, how was the onnx model generated? But ceil_mode==0 is the default anyway so I've pushed a fix that should accept it. Please double check that you get the right size of the output tensor from your maxpool layer.

On Tue, May 5, 2020 at 11:44 PM Aitik Gupta notifications@github.com wrote:

Here's a MaxPool layer (from an onnx) with following attributes:

{'ceil_mode': 0, 'kernel_shape': (3, 3), 'pads': (1, 1, 1, 1), 'strides': (2, 2)}

Here's the traceback:

Traceback (most recent call last): File "onnx2keras.py", line 460, in main() File "onnx2keras.py", line 452, in main model = onnx2keras(onnx.load(infile)) File "onnx2keras.py", line 440, in onnx2keras output_tensors = ops.make_op(node.op_type, inputs, attrs) File "onnx2keras.py", line 25, in makeop return getattr(self, 'op' + op_type.lower())(*inputs, **attrs) TypeError: op_maxpool() got an unexpected keyword argument 'ceil_mode'

Is this a TF1.x vs TF2.x issue, if not, could you provide more insights?

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/AxisCommunications/onnx-to-keras/issues/3, or unsubscribe https://github.com/notifications/unsubscribe-auth/AA2GZ4JP5V2G6DGZQLE6TRLRQCCEFANCNFSM4MZ52EJA .

-- Håkan Ardö

aitikgupta commented 4 years ago

Don't know, how was the onnx model generated? But ceil_mode==0 is the default anyway so I've pushed a fix that should accept it. Please double check that you get the right size of the output tensor from your maxpool layer. On Tue, May 5, 2020 at 11:44 PM Aitik Gupta @.> wrote: Here's a MaxPool layer (from an onnx) with following attributes: {'ceil_mode': 0, 'kernel_shape': (3, 3), 'pads': (1, 1, 1, 1), 'strides': (2, 2)} Here's the traceback: Traceback (most recent call last): File "onnx2keras.py", line 460, in main() File "onnx2keras.py", line 452, in main model = onnx2keras(onnx.load(infile)) File "onnx2keras.py", line 440, in onnx2keras output_tensors = ops.make_op(node.op_type, inputs, attrs) File "onnx2keras.py", line 25, in makeop return getattr(self, 'op' + op_type.lower())(inputs, attrs) TypeError: op_maxpool() got an unexpected keyword argument 'ceil_mode' Is this a TF1.x vs TF2.x issue, if not, could you provide more insights? — You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub <#3>, or unsubscribe https://github.com/notifications/unsubscribe-auth/AA2GZ4JP5V2G6DGZQLE6TRLRQCCEFANCNFSM4MZ52EJA . -- Håkan Ardö

onnx file was generated by PyTorch, ceil_mode should have been 0 by default I suppose. Anyway the fix worked, and I have the right size of output tensor from the maxpool layer.

Thanks! I'm closing this issue now.