Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tf2onnx.tfonnx:Tensorflow op [sequential_1_1/lstm_1/CudnnRNNV3: CudnnRNNV3] is not supported #2359

Open
nassimus26 opened this issue Oct 12, 2024 · 0 comments
Labels
unsupported ops Issues related to unsupported operators

Comments

@nassimus26
Copy link

New Operator

Having this TensorFlow model

nbr_frame = 10
img_width = 180
img_height = 150
img_size = (img_height, img_width)
input_shape = (3,) + img_size
full_input_shape = (nbr_frame,) + input_shape
print(full_input_shape)
np.random.seed(1234)
num_classes = 2
tf.keras.backend.set_image_data_format(
    'channels_first'
)
#vg19 = tf.keras.applications.vgg19.VGG19
#base_model = vg19(include_top=False,weights='imagenet',input_shape=(img_width, img_height,3))
base_model = tf.keras.applications.MobileNetV2(
    include_top=False, weights='imagenet', input_tensor=None,
    input_shape = input_shape,
    pooling=None, 
)
for layer in base_model.layers:
    layer.trainable = False
base_model.summary()
cnn = models.Sequential()
cnn.add(base_model)
cnn.add(layers.GlobalAveragePooling2D())
cnn.add(layers.Dropout(0.2))
base_model.trainable = False
# define LSTM model
model = models.Sequential()
print(full_input_shape)
model.add(layers.TimeDistributed(cnn, input_shape=full_input_shape))
model.add(layers.LSTM(nbr_frame, return_sequences=True))
model.add(layers.TimeDistributed(layers.Dense(nbr_frame, activation='relu')))
model.add(layers.Flatten())
model.add(layers.Dense(164, activation='relu', name="filter"))
model.add(layers.Dropout(0.2))
model.add(layers.Dense(24, activation='sigmoid', name="filter2"))
model.add(layers.Dropout(0.1))
model.add(layers.Dense(num_classes, activation="sigmoid", name="last"))
rms = optimizers.RMSprop()
metrics = [tf.keras.metrics.CategoricalAccuracy('accuracy', dtype=tf.float32)]
loss = tf.keras.losses.CategoricalCrossentropy()

model.compile(
    loss=loss,
    optimizer= rms,
    metrics=metrics
)
model.summary()

Running the conversion

input_signature = [tf.TensorSpec((None,) + full_input_shape, tf.float32, name='x')]
# Use from_function for tf functions
# model.output_names=['output']
onnx_model, _ = tf2onnx.convert.from_keras(model, input_signature, opset=18)
onnx.save(onnx_model, "fights.onnx")

Return this

WARNING:tf2onnx.shape_inference:Cannot infer shape for sequential_1_1/lstm_1/CudnnRNNV3: sequential_1_1/lstm_1/CudnnRNNV3:3,sequential_1_1/lstm_1/CudnnRNNV3:4
ERROR:tf2onnx.tfonnx:Tensorflow op [sequential_1_1/lstm_1/CudnnRNNV3: CudnnRNNV3] is not supported
ERROR:tf2onnx.tfonnx:Unsupported ops: Counter({'CudnnRNNV3': 1})

More about this operation here :

https://www.tensorflow.org/api_docs/java/org/tensorflow/op/core/CudnnRNNV3

@nassimus26 nassimus26 added the unsupported ops Issues related to unsupported operators label Oct 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
unsupported ops Issues related to unsupported operators
Projects
None yet
Development

No branches or pull requests

1 participant