Skip to content

Commit 2695287

Browse files
committed
update install_keras to use legacy keras
1 parent 7bcf40e commit 2695287

3 files changed

Lines changed: 37 additions & 6 deletions

File tree

R/install.R

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,20 @@
1-
#' Install TensorFlow and Keras, including all Python dependencies
1+
#' Install TensorFlow and Legacy Keras, including all Python dependencies
2+
#'
3+
#' This function can be used to create a persistent virtual environment.
4+
#' Note that recent versions of reticulate will automatically manage environemnts
5+
#' if dependencies are declared with `reticulate::py_require()`. Instead of using
6+
#' this `install_keras()` function, new users are encouraged instead to run this code at the start of the R session, before loading keras:
7+
#'
8+
#' ```r
9+
#' # declare requirements for legacy keras (tf-keras)
10+
#' reticulate::py_require(c("tensorflow", "tf-keras", "numpy<2"))
11+
#'
12+
#' # also declare optional dependencies
13+
#' reticulate::py_require(c(
14+
#' "tensorflow-hub", "tensorflow-datasets", "scipy",
15+
#' "requests", "Pillow", "h5py", "pandas", "pydot"
16+
#' ))
17+
#' ```
218
#'
319
#' This function will install Tensorflow and all Keras dependencies. This is a
420
#' thin wrapper around [`tensorflow::install_tensorflow()`], with the only
@@ -44,7 +60,7 @@ install_keras <- function(method = c("auto", "virtualenv", "conda"),
4460
method = method,
4561
conda = conda,
4662
version = tensorflow,
47-
extra_packages = pkgs,
63+
extra_packages = c(pkgs, "tf-keras"),
4864
# envname = envname,
4965
# new_env = new_env,
5066
...

R/package.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ keras <- NULL
115115

116116
reticulate::py_require(
117117
c(
118-
"tf-keras",
118+
"tf-keras", "tensorflow",
119119
"numpy<2",
120120
as.vector(default_extra_packages())
121121
)

man/install_keras.Rd

Lines changed: 18 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)