Skip to content

Conversation

@EmilHvitfeldt
Copy link
Member

This PR aims to close #613 and close #596.

With the changes to tensorflow, internal functions have been updated to reflect deprecated functions.

@EmilHvitfeldt EmilHvitfeldt requested a review from topepo January 26, 2022 22:34
Copy link
Member

@topepo topepo left a comment

Choose a reason for hiding this comment

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

Also, please make an entry in the news file about this.

@EmilHvitfeldt EmilHvitfeldt requested a review from topepo February 4, 2022 05:40
Merge commit '8f26aaaa9c170c58d33f24a895970fc58bf7101d'

Conflicts:
	.github/workflows/R-CMD-check.yaml
@EmilHvitfeldt
Copy link
Member Author

This PR tries to handle a couple of different problems.

The first problem is the error emitted by Keras as mentioned in #613 and #596, where predict_classes and predict_proba were changed. There is now a conditional (version(keras) >= 2.6) on the package version of keras to switch between using predict() and predict_proba()

Secondly the use of keras::k_argmax() is conditioned to be used when the tensorflow version is v2.

Lastly, set_tf_seed() has been added, exported and used in tests. This function sets seed in R and tensorflow at the same time, conditionally switching between tensorflow::tf$random$set_seed and tensorflow::tf$random$set_random_seed for v1 and v2 respectively.

I have tested these changes locally using all combinations that could be installed together of

  • Keras: 2.7.0, 2.6.1, 2.6.0, 2.4.0
  • Tensorflow: 2.7.1, 2.6.3, 1.15.0

@topepo topepo merged commit 68dfd60 into main Feb 9, 2022
@topepo topepo deleted the update-keras branch February 9, 2022 02:18
@github-actions
Copy link
Contributor

This pull request has been automatically locked. If you believe you have found a related problem, please file a new issue (with a reprex: https://reprex.tidyverse.org) and link to this issue.

@github-actions github-actions bot locked and limited conversation to collaborators Feb 24, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

AttributeError: 'Sequential' object has no attribute 'predict_classes' Update keras code

4 participants