Skip to content

Commit

Permalink
Update serialize and deserialize imports (#365)
Browse files Browse the repository at this point in the history
* [nightly] Increase version to 0.18.0.dev12

* Change import to use TF keras legacy utils to access serialize and deserialize.

* Add try/except to handle updated import path in tf 2.13

---------

Co-authored-by: Github Actions Bot <[email protected]>
  • Loading branch information
owenvallis and actions-user authored Oct 23, 2023
1 parent 619d1fe commit ad4f815
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 13 deletions.
2 changes: 1 addition & 1 deletion tensorflow_similarity/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
__version__ = "0.18.0.dev11"
__version__ = "0.18.0.dev12"


from . import models # noqa
Expand Down
13 changes: 13 additions & 0 deletions tensorflow_similarity/augmenters/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
# Copyright 2021 The TensorFlow Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
from .augmenter import Augmenter # noqa
from .barlow import BarlowAugmenter # noqa
from .contrastive import ContrastiveAugmenter # noqa
Expand Down
11 changes: 7 additions & 4 deletions tensorflow_similarity/distances/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,13 @@

from typing import Any, Type

from tensorflow.python.keras.utils.generic_utils import (
deserialize_keras_object,
serialize_keras_object,
)
try:
from tensorflow.keras.utils import deserialize_keras_object, serialize_keras_object
except ImportError:
from tensorflow.keras.utils.legacy import (
deserialize_keras_object,
serialize_keras_object,
)

from .cosine import CosineDistance # noqa
from .distance import Distance # noqa
Expand Down
11 changes: 7 additions & 4 deletions tensorflow_similarity/search/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,13 @@

from typing import Any, Type

from tensorflow.python.keras.utils.generic_utils import (
deserialize_keras_object,
serialize_keras_object,
)
try:
from tensorflow.keras.utils import deserialize_keras_object, serialize_keras_object
except ImportError:
from tensorflow.keras.utils.legacy import (
deserialize_keras_object,
serialize_keras_object,
)

from .faiss import FaissSearch # noqa
from .linear import LinearSearch # noqa
Expand Down
11 changes: 7 additions & 4 deletions tensorflow_similarity/stores/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,13 @@

from typing import Any, Type

from tensorflow.python.keras.utils.generic_utils import (
deserialize_keras_object,
serialize_keras_object,
)
try:
from tensorflow.keras.utils import deserialize_keras_object, serialize_keras_object
except ImportError:
from tensorflow.keras.utils.legacy import (
deserialize_keras_object,
serialize_keras_object,
)

from .cached import CachedStore # noqa
from .memory import MemoryStore # noqa
Expand Down

0 comments on commit ad4f815

Please sign in to comment.