recommenders icon indicating copy to clipboard operation
recommenders copied to clipboard

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

Open malinphy opened this issue 10 months ago • 1 comments

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 avatar Dec 11 '24 19:12 malinphy