Skip to content
This repository has been archived by the owner on Oct 13, 2021. It is now read-only.

Can't convert CRF model with input dtype variant #732

Open
saeedehkhoshgoftar opened this issue Jul 14, 2021 · 0 comments
Open

Can't convert CRF model with input dtype variant #732

saeedehkhoshgoftar opened this issue Jul 14, 2021 · 0 comments

Comments

@saeedehkhoshgoftar
Copy link

Hi,

I am trying to accelerate a NLP pipeline using keras-onnx. The Keras model consisting a CRF layer (tf2crf) on top of the BiLSTM layer. I faced a following error: ValueError: Unable to find out a correct type for tensor type = <dtype: 'variant'> of sequential/crf/scan/while/exit/_103:0

I would appreciate it if you could direct me how to run the model via keras_onnx

def build_model():
    model = tf.keras.models.Sequential()

    model.add(tf.keras.layers.Bidirectional(tf.keras.layers.LSTM(internal_unit, return_sequences=True), input_shape=(seq_length, vector_dim)))
    if drop_out_rate >0 and drop_out_rate <1:
        model.add(tf.keras.layers.Dropout(drop_out_rate))
    model.add(tf.keras.layers.TimeDistributed(tf.keras.layers.Dense(num_tags, activation=activation)))
    crf = CRF(num_tags)
    model.add(crf)
   model.compile (loss=crf.loss, metrics=[crf.accuracy], optimizer=model_optimizer)
        
    return model
model = build_model()
model.load_weights("model.h5")
onnx_model = keras2onnx.convert_keras(model, model.name)

The output is:
ValueError: Unable to find out a correct type for tensor type = <dtype: 'variant'> of sequential_1/crf_1/scan/while/exit/_103:0

Is it an onnx error or am I missing something?

Versions:

Python: 3.7.10
Tensorflow: 2.3.0
Keras: 2.2.4
tf2crf: 0.1.13

Thanks!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant