Skip to content

fix R_Square shape issue in model.evaluate #2034

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

Merged
merged 3 commits into from
Jul 27, 2020
Merged

fix R_Square shape issue in model.evaluate #2034

merged 3 commits into from
Jul 27, 2020

Conversation

schmidt-jake
Copy link
Contributor

@schmidt-jake schmidt-jake commented Jul 24, 2020

Description

The R_Square metric was broken when calling model.evaluate or model.fit with validation_data set. This was due to a tensor shape mismatch.

Fixes # (issue)

Type of change

How Has This Been Tested?

If you're adding a bugfix or new feature please describe the tests that you ran to verify your changes:

  • I added to metrics/test/r_square_test.py:
def test_keras_fit():
    model = tf.keras.Sequential([tf.keras.layers.Dense(1)])
    model.compile(loss="mse", metrics=[RSquare(y_shape=(1,))])
    data = tf.data.Dataset.from_tensor_slices(
        (tf.random.normal(shape=(100, 1)), tf.random.normal(shape=(100, 1)))
    )
    data = data.batch(10)
    model.fit(x=data)
    model.fit(x=data, validation_data=data)

Checklist:

  • I've properly formatted my code according to the guidelines
    • By running Black + Flake8
    • By running pre-commit hooks
  • This PR addresses an already submitted issue for TensorFlow Addons
  • I have made corresponding changes to the documentation
  • I have added tests that prove my fix is effective or that my feature works
  • This PR contains modifications to C++ custom-ops

@bot-of-gabrieldemarmiesse

@marload @SSaishruthi

You are owners of some files modified in this pull request.
Would you kindly review the changes whenever you have the time to?
Thank you very much.

@bhack bhack added the metrics label Jul 24, 2020
@bhack bhack self-requested a review July 24, 2020 00:09
@bhack
Copy link
Contributor

bhack commented Jul 24, 2020

Thanks. See the first point on the checklist.

@archsyscall
Copy link
Contributor

Thank You!

Could you solve the test failure?

First of all, flake8 will be solved by removing the import of weights_broadcast_ops, which is an unused function.
Also, the test_r2_sklearn_comparison has an error.

@schmidt-jake
Copy link
Contributor Author

@marload I believe I made all the necessary changes. All the tests are passing except one build... is this my fault? Please advise.

@archsyscall
Copy link
Contributor

The failed test seems to fail in all other PRs. I think you'd better write an Issue.

@WindQAQ WindQAQ self-requested a review July 27, 2020 18:12
Copy link
Member

@WindQAQ WindQAQ left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks 😄

@WindQAQ WindQAQ merged commit 3686bdd into tensorflow:master Jul 27, 2020
jrruijli pushed a commit to jrruijli/addons that referenced this pull request Dec 23, 2020
* fix R_Square shape issue in model.evaluate

* add test

* remove erroneous line in test
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants