Keras: Difference between revisions

From Alliance Doc
Jump to navigation Jump to search
No edit summary
(rm links to unwritten pages)
 
(19 intermediate revisions by 6 users not shown)
Line 1: Line 1:
{{Draft}}
<languages />
[[Category:Software]][[Category:AI and Machine Learning]]
<translate>
<!--T:1-->
"Keras is a high-level neural networks API, written in Python and capable of running on top of TensorFlow, CNTK, or Theano."<ref>https://keras.io/</ref>


"Keras is a high-level neural networks API, written in Python and capable of running on top of TensorFlow, CNTK, or Theano. It was developed with a focus on enabling fast experimentation."<ref>https://keras.io/</ref>
<!--T:9-->
If you are porting a Keras program to one of our clusters, you should follow [[Tutoriel Apprentissage machine/en|our tutorial on the subject]].


==Installing==
==Installing== <!--T:2-->


#Install either [[Tensorflow]], [[CTNK]] or [[Theano]].
<!--T:3-->
#Activate the Python virtual environment in which you installed one of the preceding package (assuming you used a virtual environment named <tt>$HOME/deeplearning</tt>),
#Install [[TensorFlow]], CNTK, or Theano in a Python [[Python#Creating_and_using_a_virtual_environment|virtual environment]].
#:{{Command2|source $HOME/deeplearning/bin/activate}}
#Activate the Python virtual environment (named <tt>$HOME/tensorflow</tt> in our example).
#Install keras in your virtual environment.
#:{{Command2|source $HOME/tensorflow/bin/activate}}
#Install Keras in your virtual environment.
#:{{Command2
#:{{Command2
|prompt=(deeplearning)_[name@server ~]$
|prompt=(tensorflow)_[name@server ~]$
|pip install keras}}
|pip install keras}}


=== R package ===
=== R package === <!--T:4-->


<!--T:5-->
This section details how to install Keras for R and use TensorFlow as the backend.
This section details how to install Keras for R and use TensorFlow as the backend.


#Install TensorFlow for R by following the instructions provided [[Tensorflow#R_package | here]].
<!--T:6-->
#Install TensorFlow for R by following [[Tensorflow#R_package | these instructions]].
#Follow the instructions from the parent section.
#Follow the instructions from the parent section.
#Load the required modules :
#Load the required modules.
#:{{Command2|module load gcc r/3.5.0}}
#:{{Command2|module load gcc/7.3.0 r/3.5.2}}
# Launch R
# Launch R.
#:{{Command2|R}}
#:{{Command2|R}}
#In R, install package keras with devtools:
#In R, install the Keras package with <code>devtools</code>.
#:<syntaxhighlight lang='r'>
#:<syntaxhighlight lang='r'>
devtools::install_github('rstudio/keras')
devtools::install_github('rstudio/keras')
Line 29: Line 37:




You are then good to go. Do not call <code>install_keras()</code> in R, as Keras and TensorFlow have already been installed in your virtual environment with pip. To use the Keras installed in your virtual environment, enter the following commands in R after the activation of the environment.
<!--T:7-->
You are then good to go. Do not call <code>install_keras()</code> in R, as Keras and TensorFlow have already been installed in your virtual environment with <code>pip</code>. To use the Keras package installed in your virtual environment, enter the following commands in R after the environment has been activated.
<syntaxhighlight lang='r'>
<syntaxhighlight lang='r'>
library(keras)
library(keras)
Line 35: Line 44:
</syntaxhighlight>
</syntaxhighlight>


== References ==
== References == <!--T:8-->
</translate>

Latest revision as of 16:11, 27 June 2023

Other languages:

"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 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).
    [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 these instructions.
  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