How to setup Keras and TensorFlow in RStudio on windows | by Greg James


I had to use Keras and TensorFlow in R for an assignment in class; however, my Linux system crashed and I had to use RStudio on windows. For the life of me, I could not get Keras up and running out of the box or find a good tutorial on how to set it up. I did some research, and these are the steps I used to finally get it working. Hope this saves someone some time!

Keras and TensorFlow both depend on python to work. I had issues getting Python 3 to work. So I decided to go with Anaconda, the data science-focused distribution of python, download and install this version of anaconda. It’s version 3.7 but this is the version that that worked for me. I kept getting setup errors with the current version of Anaconda. During the install, remember to check the boxes to add anaconda to your path and set it as the default python. You can create a virturalenv if you want but for simplicity’s sake, we are just going to use the base anaconda environment for the rest of this guide.

In order for R to be able to talk to Python, we need to install Reticulate. So run install.packages(“reticulate”) in RStudio. This will download and install the Retuculate package for R.

Run pip install tensorflow and pip install keras to install both of these libraries in python. You can test the TensorFlow installation by running import tensorflow as tf from python. If you get no errors, you are ready to proceed to the next step!

From RStudio/R run the commands install.packages(“tensorflow”) and install.packages(“keras”). Next, load the TensorFlow library by running library(tensorflow). Finally, install the dependencies by running install_tensorflow(). Once that is completed, do the same for Keras: run library(keras) and then run install_keras()

You can test the install by running library(keras) and some Keras code in a notebook. If you receive no errors then you are good to go! If you do receive some errors, comment below and I will try my best to help you.

Thank you for reading, please 👏 and share to help others find it.

See you soon. 😃



Source link

Be the first to comment

Leave a Reply

Your email address will not be published.


*