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

use_session_with_seed is deprecated in Keras 2.6.0 #1330

Open
boxydog opened this issue Apr 22, 2022 · 4 comments
Open

use_session_with_seed is deprecated in Keras 2.6.0 #1330

boxydog opened this issue Apr 22, 2022 · 4 comments

Comments

@boxydog
Copy link

boxydog commented Apr 22, 2022

I tried

library(keras)
keras::use_session_with_seed(
    SEED,
    disable_gpu = FALSE,
    disable_parallel_cpu = FALSE)

on Kaggle, and it says:

Warning message in keras::use_session_with_seed(SEED, disable_gpu = FALSE, disable_parallel_cpu = FALSE):
“use_session_with_seed will be deprecated in the future. use set_random_seed instead.”
Error in keras::use_session_with_seed(SEED, disable_gpu = FALSE, disable_parallel_cpu = FALSE): use_session_with_seed will be deprecated in the future. use set_random_seed instead.
Traceback:

  1. keras::use_session_with_seed(SEED, disable_gpu = FALSE, disable_parallel_cpu = FALSE)
  2. stop(msg)

However, set_random_seed does not look to be exported:

keras::set_random_seed(SEED)
Error: 'set_random_seed' is not an exported object from 'namespace:keras'

set_random_seed looks exported from tensorflow, but I'm not sure if it has the same functionality.

Versions:

packageVersion('keras')
[1] ‘2.6.0’

foo <- reticulate::py_run_string('import keras;  vers=keras.__version__')
foo$vers
'2.6.0'
@t-kalinowski
Copy link
Member

Hi, thanks for filing. set_random_seed is exported by the {tensorflow} package. You can access it with tensorflow::set_random_seed()

@boxydog
Copy link
Author

boxydog commented Apr 22, 2022

But does it do the same thing as use_session_with_seed? That's what I'm unclear on.

The docs for use_session_with_seed say:

The provided seed value will establish a new random seed for R, Python, NumPy, and TensorFlow. GPU computations and CPU parallelism will also be disabled by default.

If it's the one to use, shouldn't the rstudio documentation point to set_random_seed instead of this deprecated function?

I'm not just asking about a function, but the expected and documented behavior.

@t-kalinowski
Copy link
Member

use_session_with_seed is a hold-over from TF v1, when users were expected to manage Sessions explicitly. It's no longer relevant in TF v2, and set_random_seed should be all you need.

You are right, the docs needs to be updated. Thank you!

@boxydog
Copy link
Author

boxydog commented Apr 22, 2022

Thanks for your help.

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

No branches or pull requests

2 participants