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

Update TF Version in setup and workflow tests #373

Open
wants to merge 16 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
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
3 changes: 0 additions & 3 deletions .github/workflows/nightly-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@ name: NightlyPublish

on:
workflow_dispatch: # Allow manual triggers
schedule:
# Runs every day at 3:07am UTC.
- cron: '7 3 * * *'

jobs:
check:
Expand Down
12 changes: 6 additions & 6 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@ jobs:
fail-fast: false
matrix:
include:
- python-version: '3.7'
- python-version: '3.8'
tf-version: '2.8'
- python-version: '3.7'
tf-version: '2.11'
- python-version: '3.9'
tf-version: '2.15.0'
- python-version: '3.10'
tf-version: '2.8'
- python-version: '3.10'
tf-version: '2.11'
- python-version: '3.11'
tf-version: '2.15.0'

steps:
- uses: actions/checkout@v2
Expand All @@ -36,7 +36,7 @@ jobs:

- name: Install TF package
run: |
pip install tensorflow==${{ matrix.tf-version }}
pip install tensorflow[and-cuda]==${{ matrix.tf-version }}
# Fix proto dep issue in protobuf 4
pip install protobuf==3.20.*

Expand Down
7 changes: 4 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ def get_version(rel_path):
author_email="[email protected]",
url="https://github.com/tensorflow/similarity",
license="Apache License 2.0",
python_requires=">=3.8",
install_requires=[
"numpy",
"pandas",
Expand Down Expand Up @@ -88,9 +89,9 @@ def get_version(rel_path):
"redis": ["redis"],
"faiss": ["faiss-gpu"],
"nmslib": ["nmslib"],
"tensorflow": ["tensorflow>=2.7,<=2.11"],
"tensorflow-gpu": ["tensorflow-gpu>=2.7,<=2.11"],
"tensorflow-cpu": ["tensorflow-cpu>=2.7,<=2.11"],
"tensorflow": ["tensorflow>=2.8,<=2.15"],
"tensorflow-gpu": ["tensorflow-gpu>=2.8,<=2.15"],
"tensorflow-cpu": ["tensorflow-cpu>=2.8,<=2.15"],
},
classifiers=[
"Development Status :: 5 - Production/Stable",
Expand Down
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.dev12"
__version__ = "0.18.0.dev13"


from . import models # noqa
Expand Down
11 changes: 6 additions & 5 deletions tensorflow_similarity/distances/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,12 +110,13 @@ def get(identifier) -> Distance:
Raises:
ValueError: If `identifier` cannot be interpreted.
"""
if isinstance(identifier, Distance):
return identifier
elif isinstance(identifier, dict):
return deserialize(identifier)
if isinstance(identifier, dict):
identifier = deserialize(identifier)
elif isinstance(identifier, str):
config = {"class_name": str(identifier), "config": {}}
return deserialize(config)
identifier = deserialize(config)

if isinstance(identifier, Distance):
return identifier
else:
raise ValueError("Could not interpret search identifier: {}".format(identifier))
11 changes: 6 additions & 5 deletions tensorflow_similarity/search/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,12 +117,13 @@ def get(identifier, **kwargs) -> Search:
Raises:
ValueError: If `identifier` cannot be interpreted.
"""
if isinstance(identifier, Search):
return identifier
elif isinstance(identifier, dict):
return deserialize(identifier)
if isinstance(identifier, dict):
identifier = deserialize(identifier)
elif isinstance(identifier, str):
config = {"class_name": str(identifier), "config": kwargs}
return deserialize(config)
identifier = deserialize(config)

if isinstance(identifier, Search):
return identifier
else:
raise ValueError("Could not interpret search identifier: {}".format(identifier))
11 changes: 6 additions & 5 deletions tensorflow_similarity/stores/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,12 +109,13 @@ def get(identifier) -> Store:
Raises:
ValueError: If `identifier` cannot be interpreted.
"""
if isinstance(identifier, Store):
return identifier
elif isinstance(identifier, dict):
return deserialize(identifier)
if isinstance(identifier, dict):
identifier = deserialize(identifier)
elif isinstance(identifier, str):
config = {"class_name": str(identifier), "config": {}}
return deserialize(config)
identifier = deserialize(config)

if isinstance(identifier, Store):
return identifier
else:
raise ValueError("Could not interpret Store identifier: {}".format(identifier))
24 changes: 1 addition & 23 deletions tests/test_layers.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import math

import tensorflow as tf
from tensorflow.keras import layers

from tensorflow_similarity.layers import (
GeneralizedMeanPooling1D,
Expand Down Expand Up @@ -160,29 +161,6 @@ def test_metric_embedding(self):
expected_result = tf.constant([[0.5, 0.5, 0.5, 0.5], [0.5, 0.5, 0.5, 0.5]])
self.assertAllClose(result, expected_result, rtol=1e-06)

def test_metric_embedding_get_config(self):
me_layer = MetricEmbedding(32)
config = me_layer.get_config()
expected_config = {
"name": "metric_embedding",
"trainable": True,
"dtype": "float32",
"units": 32,
"activation": "linear",
"use_bias": True,
"kernel_initializer": {
"class_name": "GlorotUniform",
"config": {"seed": None},
},
"bias_initializer": {"class_name": "Zeros", "config": {}},
"kernel_regularizer": None,
"bias_regularizer": None,
"activity_regularizer": None,
"kernel_constraint": None,
"bias_constraint": None,
}
self.assertEqual(expected_config, config)


if __name__ == "__main__":
tf.test.main()
Loading