You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Your MCDropout layers (or variants) work very well when designing a tensorflow.keras model, for example:
x = Dense(100, activation='relu', input_shape=(n_input,))(input_z) x = MCDropout(0.2)(x) x = Dense(100, activation='relu')(x) x = MCDropout(0.2)(x)
Now it still works fine during training, but the problem is when I want to load a model previously saved in an h5 file via something like tf.keras.models.save_model(neural_model, 'mymodel.h5' ). For earlier versions of Tensorflow, the following worked:
model = tf.keras.models.load_model('mymodel.h5', custom_objects={'MCDropout': MCDropout})
However, the newer versions of tensorflow do not work, and the following error is thrown:
deserialize_keras_object
obj = module_objects.get(object_name)
AttributeError: 'NoneType' object has no attribute 'get'
I think maybe using MCDropout after training, might work better, or redefine the method according to the new tensorflow version.
The text was updated successfully, but these errors were encountered:
igomezv
changed the title
MCDrropout incompatibility for latest Tensorflow versions
MCDropout incompatibility with latest versions of Tensorflow
Apr 16, 2024
Latest version of Tensorflow, are you referring to Tensorflow 2.16.x or 2.15.x?
Did you import Dense from tensorflow.keras or Keras directly?
If you are using Keras too, which version are you using?
Tensorflow is separating Keras (they use to be separate packages long time ago but then merged Keras under Tensorflow but now separating again...) and Keras 3.x are causing various issues for me too.
There is a git branch I've created to fix some of those issues at https://github.com/henrysky/astroNN/tree/keras3_torch. You might want to try to see if it fixes your issue. But this is an ongoing issue so I am waiting a bit to see how the situation is evolving on the Tensorflow/Keras 3.0 side.
Your MCDropout layers (or variants) work very well when designing a tensorflow.keras model, for example:
x = Dense(100, activation='relu', input_shape=(n_input,))(input_z)
x = MCDropout(0.2)(x)
x = Dense(100, activation='relu')(x)
x = MCDropout(0.2)(x)
Now it still works fine during training, but the problem is when I want to load a model previously saved in an h5 file via something like
tf.keras.models.save_model(neural_model, 'mymodel.h5' )
. For earlier versions of Tensorflow, the following worked:model = tf.keras.models.load_model('mymodel.h5', custom_objects={'MCDropout': MCDropout})
However, the newer versions of tensorflow do not work, and the following error is thrown:
deserialize_keras_object
obj = module_objects.get(object_name)
AttributeError: 'NoneType' object has no attribute 'get'
I think maybe using MCDropout after training, might work better, or redefine the method according to the new tensorflow version.
The text was updated successfully, but these errors were encountered: