onnx / keras-onnx

Convert tf.keras/Keras models to ONNX
Apache License 2.0
379 stars 109 forks source link

tf.random.shuffle supported #707

Open chan4cc opened 3 years ago

chan4cc commented 3 years ago

I'm trying to convert a keras h5 model(create with tf1.12) to ONNX:

from tensorflow.keras.models import load_model

model = load_model(my_model_file)

onnx_model = keras2onnx.convert_keras(model, model.name)
onnx_model.save_model('model.onnx')

which report a error like:

WARN: No corresponding ONNX op matches the tf.op node cos_sim/RandomShuffle_6 of type RandomShuffle
      The generated ONNX model needs run with the custom op supports.
WARN: No corresponding ONNX op matches the tf.op node cos_sim/RandomShuffle_5 of type RandomShuffle
      The generated ONNX model needs run with the custom op supports.
WARN: No corresponding ONNX op matches the tf.op node cos_sim/RandomShuffle_4 of type RandomShuffle
      The generated ONNX model needs run with the custom op supports.
WARN: No corresponding ONNX op matches the tf.op node cos_sim/RandomShuffle_3 of type RandomShuffle
      The generated ONNX model needs run with the custom op supports.
WARN: No corresponding ONNX op matches the tf.op node cos_sim/RandomShuffle_2 of type RandomShuffle
      The generated ONNX model needs run with the custom op supports.
WARN: No corresponding ONNX op matches the tf.op node cos_sim/RandomShuffle_1 of type RandomShuffle
      The generated ONNX model needs run with the custom op supports.
WARN: No corresponding ONNX op matches the tf.op node cos_sim/RandomShuffle of type RandomShuffle
      The generated ONNX model needs run with the custom op supports.
There is an error(<class 'StopIteration'>) happened during optimizing on the converted model!

I tried pass param custom_op_conversions with {'RandomShuffle': tf.random.shuffle}, and it report the same error. it seems that keras2onnx not support op tf.random.shuffle yet?

Version Used: tensorflow: 1.12 onnxconverter-common: 1.8.1 keras2onnx: 1.8.0