tensorflow / tensorflow/recommenders
ValueError: The shape of the target variable and the shape of the target value in `variable.assign(value)` must match in layers/factorized_top_k.py
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 2k
- Forks
- 300
- PR merge metrics
- No merged PRs in 30d
Description
Getting below error when trying Quickstart example.
File "/Users/terry/Documents/project/recommender/recommenders/collab_filtering_movie.py", line 245, in
index.index_from_dataset(
File "/Users/terry/Documents/project/recommender/recommenders/tensorflow_recommenders/layers/factorized_top_k.py", line 215, in index_from_dataset
return self.index(candidates, identifiers)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/terry/Documents/project/recommender/recommenders/tensorflow_recommenders/layers/factorized_top_k.py", line 564, in index
self._identifiers.assign(identifiers)
File "/Users/terry/Documents/project/recommender/recommenders/.venv/lib/python3.12/site-packages/keras/src/backend/common/variables.py", line 226, in assign
raise ValueError(
ValueError: The shape of the target variable and the shape of the target value invariable.assign(value)must match. variable.shape=(), Received: value.shape=(1682,). Target variable:
OSX 14.2.1
python 3.12
tensorflow 2.16.2
tensorflow-recommenders 0.7.3
tensorflow-datasets 4.9.6
keras 3.4.1
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the Quickstart example with the listed Python, TensorFlow, TensorFlow Recommenders, TensorFlow Datasets, and Keras versions. Start in layers/factorized_top_k.py at index_from_dataset around line 215 and index around line 564, then trace how identifiers are initialized before assign is called. Done means the example no longer raises the reported shape error, with the behavior verified against the affected versions.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python, tensorflow
- Domain
- backend, machine-learning
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100