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

RSquare TypeError: tf__update_state() got an unexpected keyword argument 'sample_weight' #1229

Closed
lotest opened this issue Mar 6, 2020 · 2 comments · Fixed by #1230
Closed
Labels
bug Something isn't working

Comments

@lotest
Copy link

lotest commented Mar 6, 2020

System information

  • OS Platform and Distribution (e.g., Linux Ubuntu 16.04): ubuntu 18.04
  • TensorFlow version and how it was installed (source or binary): 2.1.0 binary (conda)
  • TensorFlow-Addons version and how it was installed (source or binary): 0.8.3 binary(pip)
  • Python version: 3.7.6
  • Is GPU used? (yes/no): yes

Describe the bug

The code goes wrong when I add "tfa.metrics.RSquare(dtype=tf.float32)" to model metrics.
The exception is "TypeError: tf__update_state() got an unexpected keyword argument 'sample_weight'"

And I don't see "sample_weight" parameter , what been added shown in #564 , of update_state() function in class RSquare in addons version 0.8.3.

Are there something wrong with my installed tensorflow and addons package?

Code to reproduce the issue

Usage in my code:

model.compile(
        loss='mse',
        optimizer=optimizer,
        metrics=['mae', 'mse', tfa.metrics.RSquare(dtype=tf.float32)]
    )

Other info / logs

Include any logs or source code that would be helpful to diagnose the problem. If including tracebacks, please include the full traceback. Large logs and files should be attached.

@gabrieldemarmiesse gabrieldemarmiesse added the bug Something isn't working label Mar 6, 2020
@gabrieldemarmiesse
Copy link
Member

@lotest #564 was not merged, that's why you don't see sample_weight being available. The problem here is that some of the metrics in TFA do not take a sample_weight argument because they don't use it. It's a problem though because Keras will automatically pass sample weights when the user declare them. A good fix would be to add sample_weights in all metrics and enforce that the argument is present. And if the tensor is not used during the computation, then just raise a warning.

This is linked to #992 , we lack some unified tests. This will become easier once we switch to pytest for testing.

@SSaishruthi
Copy link
Contributor

@gabrieldemarmiesse will take a look at it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants