Skip to content

Keras

Keras is a high-level neural networks API, written in Python and capable of running on top of TensorFlow, CNTK, or Theano. More information can be found on the official Keras website.

Tip

If you are porting a Keras program to one of our clusters, you should follow our tutorial on the subject.

Installing

  1. Install TensorFlow, CNTK, or Theano in a Python virtual environment.
  2. Activate the Python virtual environment (named $HOME/tensorflow in our example).
    source $HOME/tensorflow/bin/activate
    
  3. Install Keras in your virtual environment.
    pip install keras
    

R package

This section details how to install Keras for R and use TensorFlow as the backend.

  1. Install TensorFlow for R by following these instructions.
  2. Follow the instructions from the parent section.
  3. Load the required modules.
    module load gcc/7.3.0 r/3.5.2
    
  4. Launch R.
    R
    
  5. In R, install the Keras package with devtools.
    devtools::install_github('rstudio/keras')
    

Once these steps are completed, Keras is ready for use. To use the Keras package installed in your virtual environment, enter the following commands in R after the environment has been activated:

Warning

Do not call install_keras() in R, as Keras and TensorFlow have already been installed in your virtual environment using pip.

```r library(keras) use_virtualenv(Sys.getenv('VIRTUAL_ENV'))