From 4ae8b7bb5d5479ba3c36266c51317946dd4b26de Mon Sep 17 00:00:00 2001 From: Hana Joo Date: Wed, 1 Jul 2026 16:20:54 -0700 Subject: [PATCH] Automated Code Change PiperOrigin-RevId: 941351156 --- setup.py | 2 +- tensorflow_recommenders/__init__.py | 2 +- tensorflow_recommenders/examples/__init__.py | 2 +- tensorflow_recommenders/examples/movielens.py | 8 +++---- tensorflow_recommenders/examples/nbtool.py | 2 +- .../experimental/__init__.py | 2 +- .../experimental/layers/__init__.py | 2 +- .../experimental/layers/embedding/__init__.py | 2 +- .../layers/embedding/partial_tpu_embedding.py | 2 +- .../embedding/partial_tpu_embedding_test.py | 2 +- .../experimental/models/__init__.py | 2 +- .../experimental/models/ranking.py | 12 +++++----- .../experimental/models/ranking_test.py | 2 +- .../experimental/optimizers/__init__.py | 2 +- .../experimental/optimizers/clippy_adagrad.py | 8 +++---- .../optimizers/clippy_adagrad_test.py | 2 +- .../optimizers/composite_optimizer.py | 2 +- .../optimizers/composite_optimizer_test.py | 2 +- tensorflow_recommenders/layers/__init__.py | 2 +- tensorflow_recommenders/layers/blocks.py | 2 +- .../layers/embedding/__init__.py | 2 +- .../layers/embedding/tpu_embedding_layer.py | 2 +- .../embedding/tpu_embedding_layer_test.py | 2 +- .../layers/factorized_top_k.py | 16 +++++++------- .../layers/factorized_top_k_test.py | 22 +++++++++---------- .../layers/feature_interaction/__init__.py | 2 +- .../layers/feature_interaction/dcn.py | 8 +++---- .../layers/feature_interaction/dcn_test.py | 2 +- .../feature_interaction/dot_interaction.py | 2 +- .../dot_interaction_test.py | 2 +- .../feature_interaction/multi_layer_dcn.py | 6 ++--- .../multi_layer_dcn_test.py | 2 +- .../layers/feature_multiplexing/__init__.py | 2 +- .../feature_multiplexing/unified_embedding.py | 6 ++--- .../unified_embedding_test.py | 2 +- tensorflow_recommenders/layers/loss.py | 4 ++-- tensorflow_recommenders/layers/loss_test.py | 2 +- tensorflow_recommenders/metrics/__init__.py | 2 +- .../metrics/factorized_top_k.py | 6 ++--- .../metrics/factorized_top_k_test.py | 2 +- tensorflow_recommenders/models/__init__.py | 2 +- tensorflow_recommenders/models/base.py | 2 +- tensorflow_recommenders/models/base_test.py | 2 +- tensorflow_recommenders/public.py | 2 +- tensorflow_recommenders/tasks/__init__.py | 2 +- tensorflow_recommenders/tasks/base.py | 2 +- tensorflow_recommenders/tasks/ranking.py | 4 ++-- tensorflow_recommenders/tasks/ranking_test.py | 2 +- tensorflow_recommenders/tasks/retrieval.py | 4 ++-- .../tasks/retrieval_test.py | 2 +- tensorflow_recommenders/types.py | 2 +- tools/build_api_docs.py | 2 +- 52 files changed, 92 insertions(+), 92 deletions(-) diff --git a/setup.py b/setup.py index 4dc99b17..772c4833 100644 --- a/setup.py +++ b/setup.py @@ -1,4 +1,4 @@ -# Copyright 2025 The TensorFlow Recommenders Authors. +# Copyright 2026 The TensorFlow Recommenders Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/tensorflow_recommenders/__init__.py b/tensorflow_recommenders/__init__.py index ce269357..a6c8cb0b 100644 --- a/tensorflow_recommenders/__init__.py +++ b/tensorflow_recommenders/__init__.py @@ -1,4 +1,4 @@ -# Copyright 2025 The TensorFlow Recommenders Authors. +# Copyright 2026 The TensorFlow Recommenders Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/tensorflow_recommenders/examples/__init__.py b/tensorflow_recommenders/examples/__init__.py index 96bcf13c..1e4a3acb 100644 --- a/tensorflow_recommenders/examples/__init__.py +++ b/tensorflow_recommenders/examples/__init__.py @@ -1,4 +1,4 @@ -# Copyright 2025 The TensorFlow Recommenders Authors. +# Copyright 2026 The TensorFlow Recommenders Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/tensorflow_recommenders/examples/movielens.py b/tensorflow_recommenders/examples/movielens.py index d3313cee..e0422c26 100644 --- a/tensorflow_recommenders/examples/movielens.py +++ b/tensorflow_recommenders/examples/movielens.py @@ -1,4 +1,4 @@ -# Copyright 2025 The TensorFlow Recommenders Authors. +# Copyright 2026 The TensorFlow Recommenders Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -65,14 +65,14 @@ def evaluate(user_model: tf.keras.Model, movie_embeddings = np.concatenate( list(movies.batch(4096).map( - lambda x: movie_model({"movie_id": x["movie_id"]}) + lambda x: movie_model({"movie_id": x["movie_id"]}) # pyrefly: ignore[not-callable] ).as_numpy_iterator())) precision_values = [] recall_values = [] for user_id, test_movies in test_user_to_movies.items(): - user_embedding = user_model({"user_id": np.array([user_id])}).numpy() + user_embedding = user_model({"user_id": np.array([user_id])}).numpy() # pyrefly: ignore[not-callable] scores = (user_embedding @ movie_embeddings.T).flatten() test_movies = np.frombuffer(test_movies, dtype=np.int32) @@ -189,4 +189,4 @@ def sample_listwise( tensor_slices["movie_title"].append(sampled_movie_titles) tensor_slices["user_rating"].append(sampled_ratings) - return tf.data.Dataset.from_tensor_slices(tensor_slices) + return tf.data.Dataset.from_tensor_slices(tensor_slices) # pyrefly: ignore[bad-argument-type] diff --git a/tensorflow_recommenders/examples/nbtool.py b/tensorflow_recommenders/examples/nbtool.py index 279aba27..90a9760b 100644 --- a/tensorflow_recommenders/examples/nbtool.py +++ b/tensorflow_recommenders/examples/nbtool.py @@ -1,4 +1,4 @@ -# Copyright 2025 The TensorFlow Recommenders Authors. +# Copyright 2026 The TensorFlow Recommenders Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/tensorflow_recommenders/experimental/__init__.py b/tensorflow_recommenders/experimental/__init__.py index 4e402da4..b0c7a37a 100644 --- a/tensorflow_recommenders/experimental/__init__.py +++ b/tensorflow_recommenders/experimental/__init__.py @@ -1,4 +1,4 @@ -# Copyright 2025 The TensorFlow Recommenders Authors. +# Copyright 2026 The TensorFlow Recommenders Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/tensorflow_recommenders/experimental/layers/__init__.py b/tensorflow_recommenders/experimental/layers/__init__.py index 08cd88d3..860b2a2d 100644 --- a/tensorflow_recommenders/experimental/layers/__init__.py +++ b/tensorflow_recommenders/experimental/layers/__init__.py @@ -1,4 +1,4 @@ -# Copyright 2025 The TensorFlow Recommenders Authors. +# Copyright 2026 The TensorFlow Recommenders Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/tensorflow_recommenders/experimental/layers/embedding/__init__.py b/tensorflow_recommenders/experimental/layers/embedding/__init__.py index 7819184e..f2a78af2 100644 --- a/tensorflow_recommenders/experimental/layers/embedding/__init__.py +++ b/tensorflow_recommenders/experimental/layers/embedding/__init__.py @@ -1,4 +1,4 @@ -# Copyright 2025 The TensorFlow Recommenders Authors. +# Copyright 2026 The TensorFlow Recommenders Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/tensorflow_recommenders/experimental/layers/embedding/partial_tpu_embedding.py b/tensorflow_recommenders/experimental/layers/embedding/partial_tpu_embedding.py index 23f5e5b3..464d639b 100644 --- a/tensorflow_recommenders/experimental/layers/embedding/partial_tpu_embedding.py +++ b/tensorflow_recommenders/experimental/layers/embedding/partial_tpu_embedding.py @@ -1,4 +1,4 @@ -# Copyright 2025 The TensorFlow Recommenders Authors. +# Copyright 2026 The TensorFlow Recommenders Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/tensorflow_recommenders/experimental/layers/embedding/partial_tpu_embedding_test.py b/tensorflow_recommenders/experimental/layers/embedding/partial_tpu_embedding_test.py index 0745939e..612d8112 100644 --- a/tensorflow_recommenders/experimental/layers/embedding/partial_tpu_embedding_test.py +++ b/tensorflow_recommenders/experimental/layers/embedding/partial_tpu_embedding_test.py @@ -1,4 +1,4 @@ -# Copyright 2025 The TensorFlow Recommenders Authors. +# Copyright 2026 The TensorFlow Recommenders Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/tensorflow_recommenders/experimental/models/__init__.py b/tensorflow_recommenders/experimental/models/__init__.py index 6d82d7df..16162a7c 100644 --- a/tensorflow_recommenders/experimental/models/__init__.py +++ b/tensorflow_recommenders/experimental/models/__init__.py @@ -1,4 +1,4 @@ -# Copyright 2025 The TensorFlow Recommenders Authors. +# Copyright 2026 The TensorFlow Recommenders Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/tensorflow_recommenders/experimental/models/ranking.py b/tensorflow_recommenders/experimental/models/ranking.py index 138609b9..776ce80f 100644 --- a/tensorflow_recommenders/experimental/models/ranking.py +++ b/tensorflow_recommenders/experimental/models/ranking.py @@ -1,4 +1,4 @@ -# Copyright 2025 The TensorFlow Recommenders Authors. +# Copyright 2026 The TensorFlow Recommenders Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -192,7 +192,7 @@ def compute_loss(self, "Got a length {len(inputs)} tuple instead: {inputs}." ) - outputs = self(features, training=training) + outputs = self(features, training=training) # pyrefly: ignore[not-callable] loss = self._task(labels, outputs, sample_weight=sample_weight) loss = tf.reduce_mean(loss) @@ -212,7 +212,7 @@ def call(self, inputs: Dict[str, tf.Tensor]) -> tf.Tensor: dense_features = inputs["dense_features"] sparse_features = inputs["sparse_features"] - sparse_embeddings = self._embedding_layer(sparse_features) + sparse_embeddings = self._embedding_layer(sparse_features) # pyrefly: ignore[not-callable] # Combine a dictionary into a vector and squeeze dimension from # (batch_size, 1, emb) to (batch_size, emb). sparse_embeddings = tf.nest.flatten(sparse_embeddings) @@ -220,10 +220,10 @@ def call(self, inputs: Dict[str, tf.Tensor]) -> tf.Tensor: sparse_embedding_vecs = [ tf.squeeze(sparse_embedding) for sparse_embedding in sparse_embeddings ] - dense_embedding_vec = self._bottom_stack(dense_features) + dense_embedding_vec = self._bottom_stack(dense_features) # pyrefly: ignore[not-callable] interaction_args = sparse_embedding_vecs + [dense_embedding_vec] - interaction_output = self._feature_interaction(interaction_args) + interaction_output = self._feature_interaction(interaction_args) # pyrefly: ignore[not-callable] if self._concat_dense: feature_interaction_output = tf.concat( [dense_embedding_vec, interaction_output], axis=1 @@ -231,7 +231,7 @@ def call(self, inputs: Dict[str, tf.Tensor]) -> tf.Tensor: else: feature_interaction_output = interaction_output - prediction = self._top_stack(feature_interaction_output) + prediction = self._top_stack(feature_interaction_output) # pyrefly: ignore[not-callable] return tf.reshape(prediction, [-1]) diff --git a/tensorflow_recommenders/experimental/models/ranking_test.py b/tensorflow_recommenders/experimental/models/ranking_test.py index 3a4e6328..76084509 100644 --- a/tensorflow_recommenders/experimental/models/ranking_test.py +++ b/tensorflow_recommenders/experimental/models/ranking_test.py @@ -1,4 +1,4 @@ -# Copyright 2025 The TensorFlow Recommenders Authors. +# Copyright 2026 The TensorFlow Recommenders Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/tensorflow_recommenders/experimental/optimizers/__init__.py b/tensorflow_recommenders/experimental/optimizers/__init__.py index 575b725f..fd645219 100644 --- a/tensorflow_recommenders/experimental/optimizers/__init__.py +++ b/tensorflow_recommenders/experimental/optimizers/__init__.py @@ -1,4 +1,4 @@ -# Copyright 2025 The TensorFlow Recommenders Authors. +# Copyright 2026 The TensorFlow Recommenders Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/tensorflow_recommenders/experimental/optimizers/clippy_adagrad.py b/tensorflow_recommenders/experimental/optimizers/clippy_adagrad.py index 2f79c3aa..1f971995 100644 --- a/tensorflow_recommenders/experimental/optimizers/clippy_adagrad.py +++ b/tensorflow_recommenders/experimental/optimizers/clippy_adagrad.py @@ -1,4 +1,4 @@ -# Copyright 2025 The TensorFlow Recommenders Authors. +# Copyright 2026 The TensorFlow Recommenders Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -175,7 +175,7 @@ def build(self, var_list: Sequence[tf.Variable]) -> None: self.add_variable_from_reference( var, "accumulator", - initial_value=initializer(shape=var.shape, dtype=var.dtype), + initial_value=initializer(shape=var.shape, dtype=var.dtype), # pyrefly: ignore[not-callable] )) if self.export_clipping_factors: self.clipping_factors.append( @@ -220,7 +220,7 @@ def update_step(self, grad: Union[tf.Tensor, tf.IndexedSlices], delta = lr * grad_values * precondition clipped_delta, clipping_factor = shrink_by_references( delta, - references=[variable_values, precondition], + references=[variable_values, precondition], # pyrefly: ignore[bad-argument-type] relative_factors=[ self.variable_relative_threshold, self.accumulator_relative_threshold @@ -235,7 +235,7 @@ def update_step(self, grad: Union[tf.Tensor, tf.IndexedSlices], # Clip the accumulator update: this acts like clipping the gradient # before sending it to the optimizer. This is a good option when the # gradient is an outlier. - accumulator_update = grad_values * clipping_factor + accumulator_update = grad_values * clipping_factor # pyrefly: ignore[unsupported-operation] else: # Does not clip the accumulator update: This is a good option in cases # where the gradient increases during training, and allows for quicker diff --git a/tensorflow_recommenders/experimental/optimizers/clippy_adagrad_test.py b/tensorflow_recommenders/experimental/optimizers/clippy_adagrad_test.py index b5c1d6eb..893aa4b4 100644 --- a/tensorflow_recommenders/experimental/optimizers/clippy_adagrad_test.py +++ b/tensorflow_recommenders/experimental/optimizers/clippy_adagrad_test.py @@ -1,4 +1,4 @@ -# Copyright 2025 The TensorFlow Recommenders Authors. +# Copyright 2026 The TensorFlow Recommenders Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/tensorflow_recommenders/experimental/optimizers/composite_optimizer.py b/tensorflow_recommenders/experimental/optimizers/composite_optimizer.py index 9632e3d5..7bda1d60 100644 --- a/tensorflow_recommenders/experimental/optimizers/composite_optimizer.py +++ b/tensorflow_recommenders/experimental/optimizers/composite_optimizer.py @@ -1,4 +1,4 @@ -# Copyright 2025 The TensorFlow Recommenders Authors. +# Copyright 2026 The TensorFlow Recommenders Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/tensorflow_recommenders/experimental/optimizers/composite_optimizer_test.py b/tensorflow_recommenders/experimental/optimizers/composite_optimizer_test.py index c1934ccc..ac94e0dc 100644 --- a/tensorflow_recommenders/experimental/optimizers/composite_optimizer_test.py +++ b/tensorflow_recommenders/experimental/optimizers/composite_optimizer_test.py @@ -1,4 +1,4 @@ -# Copyright 2025 The TensorFlow Recommenders Authors. +# Copyright 2026 The TensorFlow Recommenders Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/tensorflow_recommenders/layers/__init__.py b/tensorflow_recommenders/layers/__init__.py index 48f85865..7d5bf6ee 100644 --- a/tensorflow_recommenders/layers/__init__.py +++ b/tensorflow_recommenders/layers/__init__.py @@ -1,4 +1,4 @@ -# Copyright 2025 The TensorFlow Recommenders Authors. +# Copyright 2026 The TensorFlow Recommenders Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/tensorflow_recommenders/layers/blocks.py b/tensorflow_recommenders/layers/blocks.py index 477d3eb7..2f653fe4 100644 --- a/tensorflow_recommenders/layers/blocks.py +++ b/tensorflow_recommenders/layers/blocks.py @@ -1,4 +1,4 @@ -# Copyright 2025 The TensorFlow Recommenders Authors. +# Copyright 2026 The TensorFlow Recommenders Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/tensorflow_recommenders/layers/embedding/__init__.py b/tensorflow_recommenders/layers/embedding/__init__.py index c9920ddd..fd8b5db8 100644 --- a/tensorflow_recommenders/layers/embedding/__init__.py +++ b/tensorflow_recommenders/layers/embedding/__init__.py @@ -1,4 +1,4 @@ -# Copyright 2025 The TensorFlow Recommenders Authors. +# Copyright 2026 The TensorFlow Recommenders Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/tensorflow_recommenders/layers/embedding/tpu_embedding_layer.py b/tensorflow_recommenders/layers/embedding/tpu_embedding_layer.py index 98187d91..9999344c 100644 --- a/tensorflow_recommenders/layers/embedding/tpu_embedding_layer.py +++ b/tensorflow_recommenders/layers/embedding/tpu_embedding_layer.py @@ -1,4 +1,4 @@ -# Copyright 2025 The TensorFlow Recommenders Authors. +# Copyright 2026 The TensorFlow Recommenders Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/tensorflow_recommenders/layers/embedding/tpu_embedding_layer_test.py b/tensorflow_recommenders/layers/embedding/tpu_embedding_layer_test.py index 2ced70e9..ea04bf65 100644 --- a/tensorflow_recommenders/layers/embedding/tpu_embedding_layer_test.py +++ b/tensorflow_recommenders/layers/embedding/tpu_embedding_layer_test.py @@ -1,4 +1,4 @@ -# Copyright 2025 The TensorFlow Recommenders Authors. +# Copyright 2026 The TensorFlow Recommenders Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/tensorflow_recommenders/layers/factorized_top_k.py b/tensorflow_recommenders/layers/factorized_top_k.py index d8c75890..517088c4 100644 --- a/tensorflow_recommenders/layers/factorized_top_k.py +++ b/tensorflow_recommenders/layers/factorized_top_k.py @@ -1,4 +1,4 @@ -# Copyright 2025 The TensorFlow Recommenders Authors. +# Copyright 2026 The TensorFlow Recommenders Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -215,7 +215,7 @@ def index_from_dataset(self, candidates: tf.data.Dataset) -> "TopK": return self.index(candidates, identifiers) @abc.abstractmethod - def call( + def call( # pyrefly: ignore[bad-override] self, queries: Union[tf.Tensor, Dict[Text, tf.Tensor]], k: Optional[int] = None, @@ -284,7 +284,7 @@ def query_with_exclusions( k = k if k is not None else self._k adjusted_k = k + exclusions.shape[1] - x, y = self(queries=queries, k=adjusted_k) + x, y = self(queries=queries, k=adjusted_k) # pyrefly: ignore[not-callable] return _exclude(x, y, exclude=exclusions, k=k) @abc.abstractmethod @@ -416,7 +416,7 @@ def call( ) if self.query_model is not None: - queries = self.query_model(queries) + queries = self.query_model(queries) # pyrefly: ignore[not-callable] # Reset the element counter. self._counter.assign(0) @@ -426,7 +426,7 @@ def top_scores( ) -> Tuple[tf.Tensor, tf.Tensor]: """Computes top scores and indices for a batch of candidates.""" - scores = self._compute_score(queries, candidate_batch) + scores = self._compute_score(queries, candidate_batch) # pyrefly: ignore[bad-argument-type] if self._handle_incomplete_batches: k_ = tf.math.minimum(k, tf.shape(scores)[1]) @@ -598,9 +598,9 @@ def call( ) if self.query_model is not None: - queries = self.query_model(queries) + queries = self.query_model(queries) # pyrefly: ignore[not-callable] - scores = self._compute_score(queries, self._candidates) + scores = self._compute_score(queries, self._candidates) # pyrefly: ignore[bad-argument-type] values, indices = tf.math.top_k(scores, k=k) @@ -764,7 +764,7 @@ def call( searcher = scann_ops.searcher_from_module(self._serialized_searcher) if self.query_model is not None: - queries = self.query_model(queries) + queries = self.query_model(queries) # pyrefly: ignore[not-callable] if not isinstance(queries, tf.Tensor): raise ValueError(f"Queries must be a tensor, got {type(queries)}.") diff --git a/tensorflow_recommenders/layers/factorized_top_k_test.py b/tensorflow_recommenders/layers/factorized_top_k_test.py index 45f22678..41ab1499 100644 --- a/tensorflow_recommenders/layers/factorized_top_k_test.py +++ b/tensorflow_recommenders/layers/factorized_top_k_test.py @@ -1,4 +1,4 @@ -# Copyright 2025 The TensorFlow Recommenders Authors. +# Copyright 2026 The TensorFlow Recommenders Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -80,7 +80,7 @@ def run_save_and_restore_test(self, layer, query, num): for _ in range(num): post_serialization_results = restored(tf.constant(query)) - self.assertAllEqual(post_serialization_results, pre_serialization_results) + self.assertAllEqual(post_serialization_results, pre_serialization_results) # pyrefly: ignore[unbound-name] def run_top_k_test(self, layer_class, @@ -121,13 +121,13 @@ def run_top_k_test(self, expected_top_scores = np.take_along_axis(scores, indices, 1) expected_top_indices = candidate_indices[indices] - candidates = tf.data.Dataset.from_tensor_slices(candidates).batch( + candidates = tf.data.Dataset.from_tensor_slices(candidates).batch( # pyrefly: ignore[bad-argument-type] batch_size) if indices_dtype is not None: - identifiers = tf.data.Dataset.from_tensor_slices(candidate_indices).batch( + identifiers = tf.data.Dataset.from_tensor_slices(candidate_indices).batch( # pyrefly: ignore[bad-argument-type] batch_size) - candidates = tf.data.Dataset.zip((identifiers, candidates)) + candidates = tf.data.Dataset.zip((identifiers, candidates)) # pyrefly: ignore[bad-argument-type] # Call twice to ensure the results are repeatable. for _ in range(2): @@ -203,7 +203,7 @@ def test_scann_dataset_arg_no_identifiers(self): rng = np.random.RandomState(42) candidates = tf.data.Dataset.from_tensor_slices( - rng.normal(size=(num_candidates, 4)).astype(np.float32)) + rng.normal(size=(num_candidates, 4)).astype(np.float32)) # pyrefly: ignore[bad-argument-type] query = rng.normal(size=(num_queries, 4)).astype(np.float32) scann = factorized_top_k.ScaNN() @@ -217,9 +217,9 @@ def test_scann_dataset_arg_with_identifiers(self): rng = np.random.RandomState(42) candidates = tf.data.Dataset.from_tensor_slices( - rng.normal(size=(num_candidates, 4)).astype(np.float32)) + rng.normal(size=(num_candidates, 4)).astype(np.float32)) # pyrefly: ignore[bad-argument-type] query = rng.normal(size=(num_queries, 4)).astype(np.float32) - identifiers = tf.data.Dataset.from_tensor_slices(np.arange(num_candidates)) + identifiers = tf.data.Dataset.from_tensor_slices(np.arange(num_candidates)) # pyrefly: ignore[bad-argument-type] index = factorized_top_k.ScaNN() index.index_from_dataset(identifiers.zip(candidates).batch(100)) @@ -232,14 +232,14 @@ def test_raise_on_incorrect_input_shape( num_candidates = 100 candidates = tf.data.Dataset.from_tensor_slices( - np.random.normal(size=(num_candidates, 4)).astype(np.float32)) + np.random.normal(size=(num_candidates, 4)).astype(np.float32)) # pyrefly: ignore[bad-argument-type] identifiers = tf.data.Dataset.from_tensor_slices( - np.arange(num_candidates - 1)) + np.arange(num_candidates - 1)) # pyrefly: ignore[bad-argument-type] with self.assertRaises(ValueError): index = layer_class() index.index_from_dataset( - tf.data.Dataset.zip((identifiers.batch(20), candidates.batch(100))) + tf.data.Dataset.zip((identifiers.batch(20), candidates.batch(100))) # pyrefly: ignore[bad-argument-type] ) @parameterized.parameters(test_cases()) diff --git a/tensorflow_recommenders/layers/feature_interaction/__init__.py b/tensorflow_recommenders/layers/feature_interaction/__init__.py index e410dff8..adada7a6 100644 --- a/tensorflow_recommenders/layers/feature_interaction/__init__.py +++ b/tensorflow_recommenders/layers/feature_interaction/__init__.py @@ -1,4 +1,4 @@ -# Copyright 2025 The TensorFlow Recommenders Authors. +# Copyright 2026 The TensorFlow Recommenders Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/tensorflow_recommenders/layers/feature_interaction/dcn.py b/tensorflow_recommenders/layers/feature_interaction/dcn.py index 963fb558..cca3a906 100644 --- a/tensorflow_recommenders/layers/feature_interaction/dcn.py +++ b/tensorflow_recommenders/layers/feature_interaction/dcn.py @@ -1,4 +1,4 @@ -# Copyright 2025 The TensorFlow Recommenders Authors. +# Copyright 2026 The TensorFlow Recommenders Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -174,14 +174,14 @@ def call(self, x0: tf.Tensor, x: Optional[tf.Tensor] = None) -> tf.Tensor: x0.shape[-1], x.shape[-1])) if self._projection_dim is None: - prod_output = self._dense(x) + prod_output = self._dense(x) # pyrefly: ignore[not-callable] else: - prod_output = self._dense_v(self._dense_u(x)) + prod_output = self._dense_v(self._dense_u(x)) # pyrefly: ignore[not-callable] prod_output = tf.cast(prod_output, self.compute_dtype) if self._diag_scale: - prod_output = prod_output + self._diag_scale * x + prod_output = prod_output + self._diag_scale * x # pyrefly: ignore[unsupported-operation] return x0 * prod_output + x diff --git a/tensorflow_recommenders/layers/feature_interaction/dcn_test.py b/tensorflow_recommenders/layers/feature_interaction/dcn_test.py index 4a018c9b..ce6d74d6 100644 --- a/tensorflow_recommenders/layers/feature_interaction/dcn_test.py +++ b/tensorflow_recommenders/layers/feature_interaction/dcn_test.py @@ -1,4 +1,4 @@ -# Copyright 2025 The TensorFlow Recommenders Authors. +# Copyright 2026 The TensorFlow Recommenders Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/tensorflow_recommenders/layers/feature_interaction/dot_interaction.py b/tensorflow_recommenders/layers/feature_interaction/dot_interaction.py index 904ddeae..526d8ca7 100644 --- a/tensorflow_recommenders/layers/feature_interaction/dot_interaction.py +++ b/tensorflow_recommenders/layers/feature_interaction/dot_interaction.py @@ -1,4 +1,4 @@ -# Copyright 2025 The TensorFlow Recommenders Authors. +# Copyright 2026 The TensorFlow Recommenders Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/tensorflow_recommenders/layers/feature_interaction/dot_interaction_test.py b/tensorflow_recommenders/layers/feature_interaction/dot_interaction_test.py index e877c1b2..f34ce71f 100644 --- a/tensorflow_recommenders/layers/feature_interaction/dot_interaction_test.py +++ b/tensorflow_recommenders/layers/feature_interaction/dot_interaction_test.py @@ -1,4 +1,4 @@ -# Copyright 2025 The TensorFlow Recommenders Authors. +# Copyright 2026 The TensorFlow Recommenders Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/tensorflow_recommenders/layers/feature_interaction/multi_layer_dcn.py b/tensorflow_recommenders/layers/feature_interaction/multi_layer_dcn.py index e9bcbd43..76c30f45 100644 --- a/tensorflow_recommenders/layers/feature_interaction/multi_layer_dcn.py +++ b/tensorflow_recommenders/layers/feature_interaction/multi_layer_dcn.py @@ -1,4 +1,4 @@ -# Copyright 2025 The TensorFlow Recommenders Authors. +# Copyright 2026 The TensorFlow Recommenders Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -113,7 +113,7 @@ def build(self, input_shape): last_dim = input_shape[-1] self._dense_u_kernels, self._dense_v_kernels = [], [] - for _ in range(self._num_layers): + for _ in range(self._num_layers): # pyrefly: ignore[bad-argument-type] self._dense_u_kernels.append(tf.keras.layers.Dense( self._projection_dim, kernel_initializer=_clone_initializer(self._kernel_initializer), @@ -146,7 +146,7 @@ def call(self, x0: tf.Tensor) -> tf.Tensor: xl = x0 - for i in range(self._num_layers): + for i in range(self._num_layers): # pyrefly: ignore[bad-argument-type] prod_output = self._dense_v_kernels[i](self._dense_u_kernels[i](xl)) xl = x0 * prod_output + xl diff --git a/tensorflow_recommenders/layers/feature_interaction/multi_layer_dcn_test.py b/tensorflow_recommenders/layers/feature_interaction/multi_layer_dcn_test.py index 7df890ad..b663e1ad 100644 --- a/tensorflow_recommenders/layers/feature_interaction/multi_layer_dcn_test.py +++ b/tensorflow_recommenders/layers/feature_interaction/multi_layer_dcn_test.py @@ -1,4 +1,4 @@ -# Copyright 2025 The TensorFlow Recommenders Authors. +# Copyright 2026 The TensorFlow Recommenders Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/tensorflow_recommenders/layers/feature_multiplexing/__init__.py b/tensorflow_recommenders/layers/feature_multiplexing/__init__.py index ac6a7aa3..2d136a2b 100644 --- a/tensorflow_recommenders/layers/feature_multiplexing/__init__.py +++ b/tensorflow_recommenders/layers/feature_multiplexing/__init__.py @@ -1,4 +1,4 @@ -# Copyright 2025 The TensorFlow Recommenders Authors. +# Copyright 2026 The TensorFlow Recommenders Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/tensorflow_recommenders/layers/feature_multiplexing/unified_embedding.py b/tensorflow_recommenders/layers/feature_multiplexing/unified_embedding.py index 8932e03d..2e12716d 100644 --- a/tensorflow_recommenders/layers/feature_multiplexing/unified_embedding.py +++ b/tensorflow_recommenders/layers/feature_multiplexing/unified_embedding.py @@ -1,4 +1,4 @@ -# Copyright 2025 The TensorFlow Recommenders Authors. +# Copyright 2026 The TensorFlow Recommenders Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -173,8 +173,8 @@ def from_config(cls, config: Dict[str, Any]) -> "UnifiedEmbedding": # to rebuild the Hashing layers, and the serialized embed_layer. For the # other arguments to the initializer, we use empty "dummy" values. ue_config = UnifiedEmbeddingConfig(0, 0, 0, "") - ue_config.hashing_config = config.pop("hashing_config") - ue_config.hashing_config = {} + ue_config.hashing_config = config.pop("hashing_config") # pyrefly: ignore[read-only] + ue_config.hashing_config = {} # pyrefly: ignore[read-only] embed_layer = tf.keras.saving.deserialize_keras_object( config.pop("embed_layer")) config["config"] = ue_config diff --git a/tensorflow_recommenders/layers/feature_multiplexing/unified_embedding_test.py b/tensorflow_recommenders/layers/feature_multiplexing/unified_embedding_test.py index aa74f72e..7cf3a634 100644 --- a/tensorflow_recommenders/layers/feature_multiplexing/unified_embedding_test.py +++ b/tensorflow_recommenders/layers/feature_multiplexing/unified_embedding_test.py @@ -1,4 +1,4 @@ -# Copyright 2025 The TensorFlow Recommenders Authors. +# Copyright 2026 The TensorFlow Recommenders Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/tensorflow_recommenders/layers/loss.py b/tensorflow_recommenders/layers/loss.py index 66c08d31..1425c49d 100644 --- a/tensorflow_recommenders/layers/loss.py +++ b/tensorflow_recommenders/layers/loss.py @@ -1,4 +1,4 @@ -# Copyright 2025 The TensorFlow Recommenders Authors. +# Copyright 2026 The TensorFlow Recommenders Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -102,7 +102,7 @@ def call(self, logits: tf.Tensor, # k + 1 logit values, including the highest k negative logits and one true # logit. _, col_indices = tf.nn.top_k( - logits + labels * MAX_FLOAT, k=num_sampled, sorted=False) + logits + labels * MAX_FLOAT, k=num_sampled, sorted=False) # pyrefly: ignore[unsupported-operation] # Gather sampled logits and corresponding labels. logits = _gather_elements_along_row(logits, col_indices) diff --git a/tensorflow_recommenders/layers/loss_test.py b/tensorflow_recommenders/layers/loss_test.py index 7ae484f9..78c9fa47 100644 --- a/tensorflow_recommenders/layers/loss_test.py +++ b/tensorflow_recommenders/layers/loss_test.py @@ -1,4 +1,4 @@ -# Copyright 2025 The TensorFlow Recommenders Authors. +# Copyright 2026 The TensorFlow Recommenders Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/tensorflow_recommenders/metrics/__init__.py b/tensorflow_recommenders/metrics/__init__.py index bb7dc426..21b0b05d 100644 --- a/tensorflow_recommenders/metrics/__init__.py +++ b/tensorflow_recommenders/metrics/__init__.py @@ -1,4 +1,4 @@ -# Copyright 2025 The TensorFlow Recommenders Authors. +# Copyright 2026 The TensorFlow Recommenders Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/tensorflow_recommenders/metrics/factorized_top_k.py b/tensorflow_recommenders/metrics/factorized_top_k.py index 66e52afb..30fb7325 100644 --- a/tensorflow_recommenders/metrics/factorized_top_k.py +++ b/tensorflow_recommenders/metrics/factorized_top_k.py @@ -1,4 +1,4 @@ -# Copyright 2025 The TensorFlow Recommenders Authors. +# Copyright 2026 The TensorFlow Recommenders Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -131,7 +131,7 @@ def update_state( ) positive_scores = tf.reduce_sum( - query_embeddings * true_candidate_embeddings, axis=1, keepdims=True) + query_embeddings * true_candidate_embeddings, axis=1, keepdims=True) # pyrefly: ignore[unsupported-operation] top_k_predictions, retrieved_ids = self._candidates( query_embeddings, k=max(self._ks)) @@ -192,4 +192,4 @@ def update_state( update_ops.append(metric.update_state(top_k_accuracy, sample_weight)) return tf.group(update_ops) - \ No newline at end of file + diff --git a/tensorflow_recommenders/metrics/factorized_top_k_test.py b/tensorflow_recommenders/metrics/factorized_top_k_test.py index 1ca07554..3e36a139 100644 --- a/tensorflow_recommenders/metrics/factorized_top_k_test.py +++ b/tensorflow_recommenders/metrics/factorized_top_k_test.py @@ -1,4 +1,4 @@ -# Copyright 2025 The TensorFlow Recommenders Authors. +# Copyright 2026 The TensorFlow Recommenders Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/tensorflow_recommenders/models/__init__.py b/tensorflow_recommenders/models/__init__.py index 1111c447..2638109d 100644 --- a/tensorflow_recommenders/models/__init__.py +++ b/tensorflow_recommenders/models/__init__.py @@ -1,4 +1,4 @@ -# Copyright 2025 The TensorFlow Recommenders Authors. +# Copyright 2026 The TensorFlow Recommenders Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/tensorflow_recommenders/models/base.py b/tensorflow_recommenders/models/base.py index ca58b7bf..06322898 100644 --- a/tensorflow_recommenders/models/base.py +++ b/tensorflow_recommenders/models/base.py @@ -1,4 +1,4 @@ -# Copyright 2025 The TensorFlow Recommenders Authors. +# Copyright 2026 The TensorFlow Recommenders Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/tensorflow_recommenders/models/base_test.py b/tensorflow_recommenders/models/base_test.py index 1eaeb2dc..d8e4ed13 100644 --- a/tensorflow_recommenders/models/base_test.py +++ b/tensorflow_recommenders/models/base_test.py @@ -1,4 +1,4 @@ -# Copyright 2025 The TensorFlow Recommenders Authors. +# Copyright 2026 The TensorFlow Recommenders Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/tensorflow_recommenders/public.py b/tensorflow_recommenders/public.py index 02ec5528..c2a9e847 100644 --- a/tensorflow_recommenders/public.py +++ b/tensorflow_recommenders/public.py @@ -1,4 +1,4 @@ -# Copyright 2025 The TensorFlow Recommenders Authors. +# Copyright 2026 The TensorFlow Recommenders Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/tensorflow_recommenders/tasks/__init__.py b/tensorflow_recommenders/tasks/__init__.py index f31349e0..ce3a48a0 100644 --- a/tensorflow_recommenders/tasks/__init__.py +++ b/tensorflow_recommenders/tasks/__init__.py @@ -1,4 +1,4 @@ -# Copyright 2025 The TensorFlow Recommenders Authors. +# Copyright 2026 The TensorFlow Recommenders Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/tensorflow_recommenders/tasks/base.py b/tensorflow_recommenders/tasks/base.py index 98f225e9..ad0e1f17 100644 --- a/tensorflow_recommenders/tasks/base.py +++ b/tensorflow_recommenders/tasks/base.py @@ -1,4 +1,4 @@ -# Copyright 2025 The TensorFlow Recommenders Authors. +# Copyright 2026 The TensorFlow Recommenders Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/tensorflow_recommenders/tasks/ranking.py b/tensorflow_recommenders/tasks/ranking.py index 33591abc..70e29238 100644 --- a/tensorflow_recommenders/tasks/ranking.py +++ b/tensorflow_recommenders/tasks/ranking.py @@ -1,4 +1,4 @@ -# Copyright 2025 The TensorFlow Recommenders Authors. +# Copyright 2026 The TensorFlow Recommenders Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -86,7 +86,7 @@ def call(self, loss: Tensor of loss values. """ - loss = self._loss( + loss = self._loss( # pyrefly: ignore[not-callable] y_true=labels, y_pred=predictions, sample_weight=sample_weight) if not compute_metrics: diff --git a/tensorflow_recommenders/tasks/ranking_test.py b/tensorflow_recommenders/tasks/ranking_test.py index f034167d..b8549daa 100644 --- a/tensorflow_recommenders/tasks/ranking_test.py +++ b/tensorflow_recommenders/tasks/ranking_test.py @@ -1,4 +1,4 @@ -# Copyright 2025 The TensorFlow Recommenders Authors. +# Copyright 2026 The TensorFlow Recommenders Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/tensorflow_recommenders/tasks/retrieval.py b/tensorflow_recommenders/tasks/retrieval.py index a5fed38e..c94d3c86 100644 --- a/tensorflow_recommenders/tasks/retrieval.py +++ b/tensorflow_recommenders/tasks/retrieval.py @@ -1,4 +1,4 @@ -# Copyright 2025 The TensorFlow Recommenders Authors. +# Copyright 2026 The TensorFlow Recommenders Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -207,7 +207,7 @@ def call( scores, labels) - loss = self._loss(y_true=labels, y_pred=scores, sample_weight=sample_weight) + loss = self._loss(y_true=labels, y_pred=scores, sample_weight=sample_weight) # pyrefly: ignore[not-callable] update_ops = [] for metric in self._loss_metrics: diff --git a/tensorflow_recommenders/tasks/retrieval_test.py b/tensorflow_recommenders/tasks/retrieval_test.py index d7b8b269..2a1c324b 100644 --- a/tensorflow_recommenders/tasks/retrieval_test.py +++ b/tensorflow_recommenders/tasks/retrieval_test.py @@ -1,4 +1,4 @@ -# Copyright 2025 The TensorFlow Recommenders Authors. +# Copyright 2026 The TensorFlow Recommenders Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/tensorflow_recommenders/types.py b/tensorflow_recommenders/types.py index 6397a6de..af5ea81a 100644 --- a/tensorflow_recommenders/types.py +++ b/tensorflow_recommenders/types.py @@ -1,4 +1,4 @@ -# Copyright 2025 The TensorFlow Recommenders Authors. +# Copyright 2026 The TensorFlow Recommenders Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/tools/build_api_docs.py b/tools/build_api_docs.py index 9291a9af..54596b8f 100644 --- a/tools/build_api_docs.py +++ b/tools/build_api_docs.py @@ -1,4 +1,4 @@ -# Copyright 2025 The TensorFlow Recommenders Authors. +# Copyright 2026 The TensorFlow Recommenders Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License.