Skip to content

Failed to convert model when using opset 15 but success on opset 8 #1811

@maybeLee

Description

@maybeLee

Describe the bug
I was trying to convert a Keras model with two keras.layers.ThresholdedReLU() using tf2onnx but failed. The information of the model is as follows:

_________________________________________________________________
 Layer (type)                Output Shape              Param #   
=================================================================
 input_4 (InputLayer)        [(None, 10, 3, 3)]        0         
                                                                 
 thresholded_re_lu_4 (Thresh  (None, 10, 3, 3)         0         
 oldedReLU)                                                      
                                                                 
 thresholded_re_lu_5 (Thresh  (None, 10, 3, 3)         0         
 oldedReLU)                                                      
                                                                 
=================================================================
Total params: 0
Trainable params: 0
Non-trainable params: 0

System information

  • OS Platform and Distribution (e.g., Linux Ubuntu 16.04): Ubuntu 20.04
  • Tensorflow Version: 2.7.0
  • Python version: 3.6

To Reproduce

import tensorflow as tf
import tf2onnx

# create model
input = tf.keras.Input((10, 3, 3))
in1 = tf.keras.layers.ThresholdedReLU()(input)
output = tf.keras.layers.ThresholdedReLU()(in1)
model = tf.keras.Model(input, output)
model.summary()

# transform model
input_shape = model.layers[0].input_shape[0]
spec = (tf.TensorSpec(input_shape, tf.float32, name="input"),)
model, _ = tf2onnx.convert.from_keras(model, input_signature=spec, \
    opset=15, output_path="temp")

You may access the code here:
https://colab.research.google.com/drive/1ai4AeoWWUuZqEOdAeyAPy390QlWOuyki?usp=sharing

Screenshots
image

However, I find that when changing the opset to 8, tf2onnx can transform this model. Can you help check what's the root cause?

Metadata

Metadata

Assignees

Labels

kerasIssues related to Keraspotential bugError in codebase may cause a bug, but no concrete examples observed

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions