How to do it...

Let's create an environment in Anaconda (ensure that you have R and Python installed):

  1. Go to Anaconda Navigator from the Start menu.
  2. Click on Environments.
  3. Create a new environment and name it. Make sure that both the Python and R options are selected, as shown in the following screenshot:

  1. Install the keras library in R using the following command in RStudio or by using the Terminal of the conda environment created in the previous step:
install.packages("keras")
  1. Install keras with the tensorflow backend.
The keras library supports TensorFlow as the default backend. Theano and CNTK are other alternative backends that can be used instead of TensorFlow.

To install the CPU version, please refer to the following code:

install_keras(method = c("auto", "virtualenv", "conda"),  conda = "auto", version = "default", tensorflow = "default",  extra_packages = c("tensorflow-hub"))

For more details about this function, please go to https://keras.rstudio.com/reference/install_keras.html.

To install the GPU version, please refer to the following steps:

  1. Ensure that you have met all the installation prerequisites, including installing the CUDA and cuDNN libraries.
  2. Set the tensorflow argument's value to gpu in the install_keras() function:
install_keras(tensorflow = "gpu")

The preceding command will install the GPU version of keras in R.

..................Content has been hidden....................

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