Sign inSign up

andrie/reticulate

By andrie

•Updated over 9 years ago

The repository contains R, RStudio, Python, Anaconda and the reticulate package

Image
4

10K+

andrie/reticulate repository overview

⁠tensorflowr: Docker repository with deep learning for R.

imagedescriptionfromsizemetricsbuild status
reticulate⁠R-3.3.3, RStudio, Python 3.4.2, Anaconda and the reticulate packagerocker/rstudio:3.3.3⁠
tensorflowr⁠Adds tensorflow and keras, installed in python virtualenv and conda environmentandrie/reticulate⁠

⁠Repositories

⁠andrie/reticulate

This repository will be useful to test any R code that connects to Python using the reticulate package. The repository uses rocker/rstudio:3.3.3⁠ as the base, and adds:

  • Python 3.4.2
  • Anaconda
  • R packages for:
    • Typical development tools, including devtools, roxygen2 and rmarkdown
    • Rcpp
    • reticulate, an interface layer between R and python, installed from CRAN⁠

⁠andrie/tensorflowr

This repository builds two environments that contain tensorflow (tensorflow.org⁠) and keras (keras.io⁠):

  • Python virtual environment, containing:

    • At location /tensorflow
    • Python 3.4.2
    • tensorflow, keras and h5py
    • Activate this environment using
      source /tensorflow/bin/activate
      
    • A CRAN mirror pointing to a static MRAN snapshot of 2017-06-01
  • Anaconda environment (conda env⁠) containing:

    • conda environment tensorflow
    • Python 3.4.2
    • tensorflow, keras and h5py
    • Activate this environment using
      source activate tensorflow
      
  • The R package reticulate (available on CRAN⁠) communicates between R and python.

  • The reticulate package needs to know where python is installed, so the repository writes environment variables into the Renviron file to configure reticulate correctly:

    TENSORFLOW_PYTHON = "/tensorflow/bin/python"
    RETICULATE_PYTHON = "/tensorflow/bin/python"
    

⁠Docker instructions

⁠Pull

To pull and build the image, use:

docker pull andrie/tensorflowr

⁠Run

Since the repository contains rocker/rstudio, you can run RStudio in your web browser by pointing to https://localhost:8787⁠ if you map the ports. The following line creates a container and names it tensorflowr, so you can easily refer to this later.

docker run -d --name tensorflowr -p 8787:8787 andrie/tensorflowr

⁠Exec

To execute code inside the running container:

docker exec -ti tensorflowr bash

⁠Hello world

⁠tensorflow

To test tensorflow, try the Hallo world example from the tensorflow R package:

library(tensorflow)
sess = tf$Session()
hello <- tf$constant('Hello, TensorFlow!')
sess$run(hello)

⁠keras

To test keras, try the code from the kerasR vignette⁠:

library(kerasR)
mod <- Sequential()
mod$add(Dense(units = 50, input_shape = 13))
mod$add(Activation("relu"))
mod$add(Dense(units = 1))
keras_compile(mod,  loss = 'mse', optimizer = RMSprop())
boston <- load_boston_housing()
X_train <- scale(boston$X_train)
Y_train <- boston$Y_train
X_test <- scale(boston$X_test)
Y_test <- boston$Y_test
keras_fit(mod, X_train, Y_train,
          batch_size = 32, epochs = 200,
          verbose = 1, validation_split = 0.1)
pred <- keras_predict(mod, normalize(X_test))
sd(as.numeric(pred) - Y_test) / sd(Y_test)

⁠License

© Andrie de Vries

License: MIT

Tag summary

Content type

Image

Digest

Size

1013.1 MB

Last updated

over 9 years ago

docker pull andrie/reticulate