Keras: AttributeError: module 'tensorflow' has no attribute 'reset_default_graph'

Created on 6 Oct 2019  路  6Comments  路  Source: rstudio/keras

Hello,

When execute:

use_session_with_seed(my.seed, disable_gpu = FALSE, disable_parallel_cpu = FALSE)

got the following error:

Error in py_get_attr_impl(x, name, silent) :
AttributeError: module 'tensorflow' has no attribute 'reset_default_graph'

Platform:
OS: mac Mojave 10.14.6
R.3.6.1
RStudio: RStudio 1.2.5001
Anaconda: Anaconda3-2019.07-MacOSX-x86_64.pkg

Keras and tensorflow are installed from RStudio, as:

devtools::install_github("rstudio/keras")
library(keras)
install_keras()

Please help to fix.

Thank you!

bug

Most helpful comment

@jingweihuang This is because of the update to TensorFlow 2.0.
I'm sorry we missed that and this function was not updated before the release.

In the meantime you can use

tensorflow::tf$random$set_seed(0)

To set get reproducible results.

All 6 comments

Before install keras, I did
conda update --all
It updated successfully.

@jingweihuang This is because of the update to TensorFlow 2.0.
I'm sorry we missed that and this function was not updated before the release.

In the meantime you can use

tensorflow::tf$random$set_seed(0)

To set get reproducible results.

Thank you for prompt reply and solution! It works:-)

I'm sorry, but has this problem been updated or somewhat solved?

I get the same error, and after i run

tf$reset_default_graph <- tf$compat$v1$reset_default_graph

it just works.
but I can't do this everytime I set seed, and the alternative

tensorflow::tf$random$set_seed(0)

is just about the seed, and cannot control the GPU and CPU limit
like use_session_with_seed do.

@jingweihuang This is because of the update to TensorFlow 2.0.
I'm sorry we missed that and this function was not updated before the release.

In the meantime you can use

tensorflow::tf$random$set_seed(0)

To set get reproducible results.

This worked thank you!

We added a new tensorflow::set_random_seed90 function in tensorflow that can be used instead of use_session_with_seed.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

gundalav picture gundalav  路  3Comments

vincenhe picture vincenhe  路  7Comments

aliarsalankazmi picture aliarsalankazmi  路  4Comments

faltinl picture faltinl  路  4Comments

gokceneraslan picture gokceneraslan  路  6Comments