Keras

From CC Doc
Jump to navigation Jump to search
This site replaces the former Compute Canada documentation site, and is now being managed by the Digital Research Alliance of Canada.

Ce site remplace l'ancien site de documentation de Calcul Canada et est maintenant géré par l'Alliance de recherche numérique du Canada.

Other languages:
English • ‎français

"Keras is a high-level neural networks API, written in Python and capable of running on top of TensorFlow, CNTK, or Theano."[1]

If you are porting a Keras program to a Compute Canada cluster, you should follow our tutorial on the subject.

Installing

  1. Install either TensorFlow, CNTK or Theano in a Python virtual environment.
  2. Activate the Python virtual environment (named $HOME/tensorflow in our example).
    [name@server ~]$ source $HOME/tensorflow/bin/activate
  1. Install Keras in your virtual environment.
    (tensorflow)_[name@server ~]$ 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 the instructions provided here.
  2. Follow the instructions from the parent section.
  3. Load the required modules.
    [name@server ~]$ module load gcc/7.3.0 r/3.5.2
  1. Launch R.
    [name@server ~]$ R
  1. In R, install the Keras package with devtools.
    devtools::install_github('rstudio/keras')


You are then good to go. Do not call install_keras() in R, as Keras and TensorFlow have already been installed in your virtual environment with pip. To use the Keras package installed in your virtual environment, enter the following commands in R after the environment has been activated.

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

References