Ivar Eriksson
Ivar Eriksson

Reputation: 973

Loading Custom Model with Tensorflow 2.1

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?

Upvotes: 6

Views: 4566

Answers (1)

Pirmin Rehm
Pirmin Rehm

Reputation: 481

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.

Upvotes: 11

Related Questions