Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix SafeModeScope import #892

Merged
merged 3 commits into from
Jan 20, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion trieste/models/keras/architectures.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,11 @@
try:
SafeModeScope = tf_keras.src.saving.serialization_lib.SafeModeScope
except AttributeError: # pragma: no cover (tested but not by coverage)
SafeModeScope = contextlib.nullcontext
try:
# in TF 2.14 it's in keras but not in tf_keras (but vice versa in TF 2.16)!
from keras.src.saving.serialization_lib import SafeModeScope # type:ignore[no-redef]
except (ImportError, ModuleNotFoundError):
SafeModeScope = contextlib.nullcontext
from tensorflow_probability.python.layers.distribution_layer import DistributionLambda, _serialize

from trieste.types import TensorType
Expand Down
Loading