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

Title: ValueError when initializing tfrs.metrics.FactorizedTopK with a candidates dataset. #748

Open
malinphy opened this issue Dec 11, 2024 · 1 comment

Comments

@malinphy
Copy link

I encountered a ValueError when attempting to initialize tfrs.metrics.FactorizedTopK with a dataset of candidate embeddings in the TensorFlow Recommenders library. It appears that the function is trying to convert a string into a shape, resulting in an error. I have been trying the sample code which was given at the following web page https://www.tensorflow.org/recommenders/examples/basic_retrieval
It is not working on the given colab link.

The following line

metrics = tfrs.metrics.FactorizedTopK(
  candidates=movies.batch(128).map(movie_model)
)

gives the following error.

ValueError                                Traceback (most recent call last)

[<ipython-input-14-e82bf640c968>](https://localhost:8080/#) in <cell line: 1>()
----> 1 metrics = tfrs.metrics.FactorizedTopK(
      2   candidates=movies.batch(128).map(movie_model)
      3 )

5 frames

[/usr/local/lib/python3.10/dist-packages/keras/src/backend/common/variables.py](https://localhost:8080/#) in standardize_shape(shape)
    533             continue
    534         if not is_int_dtype(type(e)):
--> 535             raise ValueError(
    536                 f"Cannot convert '{shape}' to a shape. "
    537                 f"Found invalid entry '{e}' of type '{type(e)}'. "

ValueError: Cannot convert '('c', 'o', 'u', 'n', 't', 'e', 'r')' to a shape. Found invalid entry 'c' of type '<class 'str'>'.

image
image

@malinphy
Copy link
Author

The following solution #712 (comment) works for the given example.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant