6

I have made my own class subclassing tf.keras.Model and am trying to save and load a trained instance of it. I'm trying to follow this tutorial but every time I go to load the saved model I get the same error message: TypeError: __init__() got an unexpected keyword argument 'reduction'. I've tried adding that keyword argument to my class but it changes nothing. Any ideas?

1 Answer 1

11

I had the same problem for Tensorflow 1.14 and solved it by adding compile=False to the load function:

new_model = tf.keras.models.load_model('saved_model/my_model', compile=False)

Even with compile=False it is possible to run the model.predict() function.

The solution originates from this Tensorflow issue.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.