A Trivial Installation, A Big Bang Forward

I first installed TensorFlow on Jupyter Notebook a few months ago, but mostly I relied on various cloud platforms to work on it until I find a need to use R with TF recently. After picking up a put-aside installation of TensorFlow on R Studio (never tested), I ran into a number of problems that I spent one day+, so I thought it is worthwhile and would like to share with others. (I searched around and documents related to R tensorflow is much limited). I have been playing around with R on and off for a year, but not really proficient as I move around different platforms to know the latest technologies and earn my certifications until I need it recently for a mini project. I hope my post would be useful as it could be a piece of cake if your system is clean/flesh, and all pre-requisite ready, but it could also be very messy and daunting if you are half-way, and your are just 50/50 on skill level of installation and R/Conda/TF knowledge.

Background
a. Systems - Anaconda 4.5.11 with Jupyter Notebook, RStudio 1.1.447, Microsoft R 3.4.3.
b. I have already installed Tensorflow on Jupyter Python and found no problem
c. Also you don't know Anaconda well, it is better to understand the essential architecture - it is basically a mini server or docker / VM type that comes with its own distribution of languages, virtual sessions and installation environment
d. You should have basic background with R, Anaconda Jupyter and know briefly technically what is TensorFlow and DeepLearning
(if you are familiar with Jupyter and R but not TF, you may install, copy and paste/run the demo codes and then relearn what you are doing)
RStudio will lead the installation to a Conda virtual environment by default is: r-tensorflow
Please also beware there are at least three types of tensorflow installation 1. Native PIP, 2a.Anaconda PIP 2b Anaconda Conda (you can check out from the Conda command prompt using
I plan to run Tensorflow from either RStudio, or Jupyter Notebook and switch between platforms or languages (if this is your very first attempt on tensorflow installation, I suggested you started with Python TF on Jupyter, then R TF on RStudio, I found no documentation about R TF on Jupyter yet but it should work as fine).
There are 3 components or interfaces from R to TF:
i) . Keras - this installation gives the access to the high level Keras API to TF (Keras is not part of TF strictly speaking)
ii) TF Estimators - this give access to various basic models of TF
iii) TF Core - this gives the low level access to TF execution graph
In my installations and this blog, I covered I) and iii)
Recommended Installation Steps (TF/Keras on RStudio):
Tensor Flow Core:
devtools::install_github("rstudio/tensorflow")
library(tensorflow)
install_tensorflow()
To install Tensoflow with R, the interface from R to Tensorflow, is actually via Python, a bit indirect but according to the publication there is no other substantial degrade in performance. Also the official documents is with RStudio, although I have also tested it on Jupyter notebook R (to be detailed below)
Keras API:
Errors Encountered
The errors could be typically due to: requisite packages not installed, versions, binding, duplicated keras/TF..
1. ERROR: dependency 'generics' is not available for package 'keras'
Still when I tried to install it from RStudio, it failed for the simple way of install, so I have to download it manually and finally it worked.
2. Error - Reticulate package missing: (This is the core Interface to 'Python' tensorflow)
"Interface to 'Python' modules, classes, and functions. When calling
into 'Python', R data types are automatically converted to their equivalent 'Python'
types. When values are returned from 'Python' to R they are converted back to R
types. Compatible with all versions of 'Python' >= 2.7." (https://cran.r-project.org/web/packages/reticulate/index.html)
3. Error - cannot find python tensorflow module
The installation scan through the python and installed tensorflow... but gives this error. I don't have a clue as everything seems in place. It could be due to binding problems. I use Conda to remove the tensorflow and re-install and fix this problem (it could be due to I used pip install long ago tensorflow, but use conda to install keras this time....and they wont match up)
4. Security Error / Sha256
This is probably due to different type of install methods (conda/pip) but it appears to be warning really so I ignored them
but I will see whether they have further ramifications.
Other useful Anaconda commands
i. conda clean -a (this deep clean cached data and files in anaconda)
ii. conda env list (please note you will find a base environment, and then a r-tensorflow env)
iii. activate r-tensorflow (this activate the virtual environment)
iv. deactivate r-tensorflow (you may inspect details of installations using activate/deactivate..)
v. conda env remove --name env-name (eg. r-tensorflow) (remove and re-install if needed)
(please note r-tensorflow is default given by R-Studio)
you may not need to use the conda commands if you work entirely within notebook and RStudio. They are still useful for behind the scene checking of what is going on.
Up and Running
A. RStudio:
i) First install the TensorFlow core with the above 3 steps to set it up, then test with the little hello world:
sess = tf$Session()
hello <- tf$constant('Hello, TensorFlow!')
sess$run(hello)
ii) Second you also install Keras and try a more extensive exercise as given in the document (https://tensorflow.rstudio.com/tensorflow/)
B. Jupyter Notebook environment:
Please note that the the Jupyter (Anaconda environment) is running in a separate virtual environment (which normally is the base environment as the Python), so what is running at the back is NOT the same r-tensorflow environment
Follow each of the above 3 steps in R and Tensorflow (start with i Tensorflow core, but you can also skip, and just go to ii Keras)
(Further test-driving will be detailed in part 2)