-
Notifications
You must be signed in to change notification settings - Fork 278
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
tfrs.metrics.FactorizedTopK #712
Comments
Hello @soheil-asgari I got the same error and solved it. It is a dependency issue with the latest version of TensorFlow. In my case, in order to solve it, I installed TFRS without dependencies (pip install tensorflow-recommenders --no-deps), because I already had the needed version of tensorflow (2.11.0) and other dependencies. Here's another similar approach: https://stackoverflow.com/questions/78144515/error-initializing-factorizedtopk-in-tensorflow-recommenders-on-sagemaker-cann |
Hello @Lopera47 |
@soheil-asgari are you explicitly using Scann?, in my case I'm not. Maybe, you can try installing Scann without dependencies to not make it update TensorFlow. |
This is a bug in the implementation of the In recommenders/tensorflow_recommenders/layers/factorized_top_k.py, we find:
Note that the first argument passed to In the Keras 2.15.0 implementation of add_weight, we find:
Note that first argument is the name of the weight variable. Passing “counter” as the name in this manner works fine in Keras 2.15.0, and we won’t get the But the Keras 3.1.1 implementation of add_weight expects
So when it goes on to check for a valid shape, the shape is set to “counter”, which is not valid, and it results in The bug, therefore, is in TensorFlow Recommenders’ implementation of the |
I can confirm that is a bug with tensorflow2.16.0 and tensorflow-recommenders0.7.3 with the output error: I only was able to perform a training by downgrading tensorflow to 2.15.1 version, but i can't save model with signature_inputs, the kernel get in infinty loop, this behavior is refered on this issue |
Seems to me that this issue should be marked as a bug in TensorFlow Recommenders (see my diagnosis of exactly where the bug in the code is) and fixed ASAP. Maybe @soheil-asgari can add the Bug label? |
Hello @rlcauvin, unfortunately, I cannot add label bugs |
I'm facing the same error. Also with tensorflow version 2.15. But only for tensorflow-recommenders version 0.7.2. Any ideas? |
For now, I've worked around the TensorFlow Recommenders bug by including the following code in my notebook before installing any TensorFlow related packages:
My notebook installs I've been unable to install and import |
Alright! Thank you @rlcauvin :) |
what worked for me is
and my
|
I am still experiencing this problem on the Colab editor and runtime. I am able to define the model but when I go to set up the task: Define your objectives.task = tfrs.tasks.Retrieval(metrics=tfrs.metrics.FactorizedTopK( it throws the following exception about the shape not being properly defined in FactorizedTopK. ValueError Traceback (most recent call last) 5 frames /usr/local/lib/python3.10/dist-packages/tensorflow_recommenders/layers/factorized_top_k.py in init(self, query_model, k, handle_incomplete_batches, num_parallel_calls, sorted_order) /usr/local/lib/python3.10/dist-packages/keras/src/layers/layer.py in add_weight(self, shape, initializer, dtype, trainable, autocast, regularizer, constraint, aggregation, name) /usr/local/lib/python3.10/dist-packages/keras/src/backend/common/variables.py in init(self, initializer, shape, dtype, trainable, autocast, aggregation, name) /usr/local/lib/python3.10/dist-packages/keras/src/backend/common/variables.py in _validate_shape(self, shape) /usr/local/lib/python3.10/dist-packages/keras/src/backend/common/variables.py in standardize_shape(shape) ValueError: Cannot convert '('c', 'o', 'u', 'n', 't', 'e', 'r')' to a shape. Found invalid entry 'c' of type '<class 'str'>'. Thanks! |
hi
when i used this code i seen this error
error:
ValueError: Cannot convert '('c', 'o', 'u', 'n', 't', 'e', 'r')' to a shape. Found invalid entry 'c' of type '<class 'str'>'.
Exception ignored in: <function AtomicFunction.del at 0x7d6fc6688d60>
The text was updated successfully, but these errors were encountered: