Installing Keras and TensorFlow for R

As per the official documentation, you can install Keras simply with:

devtools::install_github("rstudio/keras")

The Keras R interface uses tensorflow as a backend engine by default. To install both the core keras library and tensorflow, then do:

library(keras)
install_keras()

However smooth this might seem, we have seen this setup fail a number of times. Our recommended plan B is:

  • Download and install the Anaconda distribution for Python. This is the standard data science stack, with the most popular Python libraries for data scientists. 
  • Install your Keras backend, for instance, Tensorflow.
  • Install Keras (within Python).

After this, you should be ready to install Keras in R.

To be sure that you are working with the most recent version of R, you can update it from R GUI (not from RStudio) using the installr package:

### Run these from RGUi
install.packages("installr")
installr::updateR()

Once you are done, you can install keras with devtools:

install.packages("devtools")
devtools::install_github("rstudio/keras")

Finally, check that everything is correct by importing the library:

library(keras)

The preceding instructions worked well for a laptop with Windows 10, running R version 3.4. If you have an older version and you do not want to update, you need to install the dependencies specified as follows (I tried this with R version 3.3):

install.packages("Rcpp")
install.packages("devtools")
devtools::install_github("rstudio/reticulate", force=TRUE)
devtools::install_github("r-lib/debugme")
devtools::install_github("r-lib/processx")
devtools::install_github("tidyverse/rlang")
devtools::install_github("tidyverse/glue")
devtools::install_github("tidyverse/tidyselect")
devtools::install_github("rstudio/tfruns")
devtools::install_github("rstudio/tensorflow")
devtools::install_github("rstudio/keras")
devtools::install_github("jeroen/jsonlite")
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset