Tensorflow loading model issue with custom activation function

57 views Asked by At

I'm using a custom activation function but when I try to load model I get the error:

Exception encountered: Unknown activation function: 'function'. Please ensure you are using a keras.utils.custom_object_scope and that this object is included in the scope. See https://www.tensorflow.org/guide/keras/save_and_serialize#registering_the_custom_object for details.

I've checked some posts and followed some suggestions as below:

custom_objects = {"custom_fn": custom_fn}

with keras.saving.custom_object_scope(custom_objects):
   Model_2 = keras.models.load_model('agent2.h5',custom_objects={"custom_fn":custom_fn})

but the error is still there.

I am using tensorflow 2.13.0. I tried tensorflow 2.15.0 but it is the same.

Can anyone help me with this problem?

Thank you,

0

There are 0 answers