when I load saved model, KeyError: 'query_shape' are occured in keras

179 Views Asked by At

I followed this timeseries classification Transformer model example in keras.

When I trained, and valided in one file, It works well.

But, when I saved that model, and import model to test file using

loadModel = tf.keras.models.load_model(baseModelPath+modelName)

occured error.

error shown like that...

---> 50         loadModel = tf.keras.models.load_model(baseModelPath+modelName)

and follows some other modules... and last error is

/usr/local/lib/python3.10/dist-packages/keras/layers/attention/multi_head_attention.py in from_config(cls, config)
    307         # If the layer has a different build() function from the Keras default,
    308         # we need to trigger the customized build to create weights.
--> 309         query_shape = config.pop("query_shape")
    310         key_shape = config.pop("key_shape")
    311         value_shape = config.pop("value_shape")

    KeyError: 'query_shape'

why this problem occured? If saved module is problem, then train code is problem. So, I think if module is problem, then train isn't work correctly. But, train and validation are really works well. So I really don't know what's the problem in this case.

I'm using google colab. Thanks for helping.

0

There are 0 best solutions below