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

ValueError: (F1Score|FBetaScore) expects 2D inputs with shape (batch_size, output_dim). #19716

Open
msusol opened this issue May 15, 2024 · 1 comment
Assignees
Labels
stat:awaiting response from contributor type:support User is asking for help / asking an implementation question. Stackoverflow would be better suited.

Comments

@msusol
Copy link

msusol commented May 15, 2024

          > I was facing a different error while executing the mentioned code.

@tilakrayal

I will show the pip list installed so my code would work in TF 2.16.1. I know I was running into an issue with datasets and had to downgrade.

See also https://www.kaggle.com/datasets/gdataranger/tf2-16-requirements-txt

# Following is based on https://github.com/huggingface/datasets/issues/6753#issuecomment-2027906687
!pip install -U datasets==2.16.0
!pip install -U fsspec==2023.10.0
!pip install -U gcsfs==2023.10.0
!pip install -U keras==3.0.5
!pip install -U ml-dtypes==0.3.2
!pip install -U numpy==1.26.4
!pip install -U seqeval
!pip install -U spacy-alignments==0.9.1
!pip install -U tensorflow~=2.16
!pip install -U tensorflow-text~=2.16
!pip install -U tf_keras~=2.16
!pip install -U transformers==4.38.2

Could you please share all the dependencies to replicate the issue.

Please find the zipfile from my 'Colab Notebooks' drive folder + data which I ran on Colab directly.
https://github.com/msusol/kaggle/blob/main/competition-20240410T165614Z-001.zip (28MB > 25MB allowed here)

Screenshot 2024-04-10 at 11 08 22 AM

Originally posted by @msusol in keras-team/tf-keras#771 (comment)

@msusol msusol changed the title Closed ValueError: (F1Score|FBetaScore) expects 2D inputs with shape (batch_size, output_dim). ValueError: (F1Score|FBetaScore) expects 2D inputs with shape (batch_size, output_dim). May 15, 2024
@SuryanarayanaY
Copy link
Collaborator

Hi @msusol ,

Thanks for reporting. Since your model is from HuggingFace you may need to check the version of TF/Keras it was built upon. Could you please submit a code snippet for reproduction.

The error happens when len(y_pred_shape) != 2 or len(y_true_shape) != 2. Could you please cross check and confirm the dimensions ? As error states this metric expects input as batched.

@SuryanarayanaY SuryanarayanaY added type:support User is asking for help / asking an implementation question. Stackoverflow would be better suited. stat:awaiting response from contributor labels May 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stat:awaiting response from contributor type:support User is asking for help / asking an implementation question. Stackoverflow would be better suited.
Projects
None yet
Development

No branches or pull requests

2 participants