I saved a tf.keras model using tf.keras.save_model
functions.
why tf.keras.load_model
throws an exception?
code example:
import tensorflow as tf
from tensorflow import keras
from tensorflow.keras import layers
model = keras.Sequential([
layers.Dense(8, activation=tf.nn.leaky_relu),
layers.Dense(8, activation=tf.nn.leaky_relu)
])
tf.keras.models.save_model(
model,
'model'
)
tf.keras.models.load_model('model')
I expect this code to load the model, but it throws an exception:
ValueError: Unknown activation function:leaky_relu
You need to add custom objects
tf.keras.models.load_model('model', custom_objects={'leaky_relu': tf.nn.leaky_relu})
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With