R: 'tensorflow not found' after importing tensorflow - r

I am trying to follow along with this tutorial on rbind.io. I thought instead of posting 30-40 lines of reproducible code, it's better to link to the tutorial.
I am trying to create a Time Series forecast using an LSTM neural network.
When following along with the code in the tutorial linked above, I was creating the Keras model from the RStudio Cloud, as my desktop RStudio was giving a different bug that could be resolved by working with the Cloud.
Moving on..
I encountered an error claiming I didn't have TensorFlow installed.
So, being the only thing to do, I installed TensorFlow.
After doing so, I encountered an error.
Now, I'm stuck. I'm not sure at all where my error is, and I request some help.
EDIT:
After trying what Ammar said, I still get an error.
EDIT 2:
Here's my reply to Ammar:

First, install the tensorflow R package from GitHub as follows:
install.packages("tensorflow")
Then, use the install_tensorflow() function to install TensorFlow as given below. Note that on Windows you need a working installation of Anaconda.
library(tensorflow)
install_tensorflow()
You can confirm that the installation succeeded with:
library(tensorflow)
tf$constant("Hellow Tensorflow")
## tf.Tensor(b'Hellow Tensorflow', shape=(), dtype=string)
As given at https://tensorflow.rstudio.com/installation/

Related

Installing Julia Packages via GitHub

To preface this question I am coming from the perspective of an absolute beginner, trying to learn Julia. I was recommended to try the SciML tutorial and in trying to install it have fallen at the first hurdle.
So far I have:
Installed Julia
Installed Anaconda
Installed Jupyter Notebook
Added "git" through the Anaconda console
Added "IJulia"
From here I have been able to open Jupyter through Anaconda and access Julia 1.7.3 within it. Following this I attempted to follow the instructions on the SciML website for getting started with the tutorial, which is to enter this code:
using Pkg
pkg"add https://github.com/SciML/SciMLTutorials.jl"
using SciMLTutorials
SciMLTutorials.open_notebooks()
However, the second line is throwing this error
invalid git HEAD (reference 'refs/heads/master' not found)
I have also tried installing the package through the Julia console, but recieve the same error.
I am at a loss of how to proceed - I can't find anything in the documentation that suggests why this may be or how to proceed - since I am so new to this I suspect I may have missed a step in my installation process, but can't figure out where that may be.

Cannot Install Library

I'm fairly new to R and have never had this issue before. I am running R v4.0.3.
I am trying to install the Tveten/capacc library for R and I am getting the following errors:
Error using install.packages
Error using devtools
I have also been to GitHub, followed the advice there and installed and ran through the source with the same error.
https://rdrr.io/github/Tveten/capacc/
If anyone has any advice, it would be very much appreciated!
EDIT: Changed names of images.

How to install package keras in R

I'm trying to install deep learning package keras on RStudio using this website. I installed keras using
install.packages("keras")
library(keras)
install_keras()
but when I tried to open the MNIST dataset
mnist <- dataset_mnist()
I keep getting the error
Error: ModuleNotFoundError: No module named 'absl'
I thought keras installed tensorflow but do I need to install tensorflow separately?
I had the same problem and it is solved by installing the package in two steps:
install keras: install.packages("keras")
keras::install_keras()
There you go!
If you follow the TUT and still got error, try running py_config() and check the python and libpython if it is pointing to an r-tensorflow environment. If not, best to try manually install keras in your manually set up conda environment.
Step 1: Install keras in your R just like in the link above.
#Open rstudio and run the following command
devtools::install_github("rstudio/keras")
#Don't close rstudio after running this, okay?
Step 2: Manually install keras (and tensorflow) in your machine ##. When i say “manual” it means using python specifically through conda. Here’s the link I followed: https://medium.com/i-want-to-be-the-very-best/installing-keras-tensorflow-using-anaconda-for-machine-learning-44ab28ff39cb .
In summary, the link will teach you to install anaconda, create an environment and install necessary libraries. Just follow it. I named my environment as “r-tensorflow” because that is the name of the environment that the install_keras() in R will do :)
Step 3: Point rstudio to use the python in your newly created environment using use_python() function
Open your rstudio (if you close it after following step 1) and type the following code
library(keras)
library(reticulate)
# in case you run into error run this : reticulate::py_discover_config("keras")
use_python("<yourpath>/Anaconda3/envs/r-tensorflow/Scripts/python.exe")
# change <yourpath> approriately
# write all the codes for building model in keras (or tensorflow) e.g. mnist<-dataset_mnist()
Important note on Step 3: If you still got the "not found module" after following step 3, you must start a new fresh R session and ensure to delete the workspace (.RData) because more likely your current script will still use the old python configuration though you used use_python
I had the same problem, but mine was solved by enclosing keras in double quotes.
install.packages("keras") ## worked for me,
install.packages(keras) ## never worked.
try:
install.packages("devtools")
devtools::install_github("rstudio/keras")
library(keras)
mnist<-dataset_mnist()
Please install "reticulate" library using command install.packages("reticulate") and then load using library(reticulate)
then install absl using command
conda_install('r-tensorflow','absl-py')

Unable to configure rHive for HDP2.4 Sandbox

Problem
I have hortonworks sandbox 2.4 on virtual box. I am following the tutorial found here for installing rHive on the sandbox. I am unable to duplicate steps 4 and 6 without producing errors. They are as follows:
Step 4 Error: Being in the ~/RHive/ directory and using ant build gives me the following error:
BUILD FAILD /root/RHive/build.xml:39: /root/RHive/usr/hdp/current/hive-server2/lib does not exist
Step 6 Error: Using R CMD INSTALL RHive_2.0-0.10.tar.gz produces the following error:
ERROR: dependencies "rJava", "Rserve" are not available for package "RHive"
Attempts
I have followed the directions as specified on here as well, which is the Rhive documents, but unfortunately have gotten nowhere.
Step 4: I am at a loss as to why ant build could be failing. I have verified I installed it correctly and it states Apache Ant(TM) version 1.9.7 compiled April 9 2016 when I run command ant -version. So I followed those procedures correctly.
Step 6:
I used rStudio to install rJava and Rserve using install.package() command. Indeed, the tutorial suggests this as well. I suspect something is wrong with my java dependencies?
I have used Ambari to use Hive before, but this is the first time I am trying to use it in R and I am abviously still new to the hortonworks vm, so I would appreciate any kindness and assistance to help me fix the issues I am encountering.
I think the answer is to abandon rHive. It was yanked from CRAN. Anyone thinking about using it with R and finds this post, please consider RJDBC.

Why does building an R package stop my code from working?

It seams that upon installing my custom R package code stops to work? Why?
In detail, I have a tiny R package goEnrichment (click to see the Github repo). The R package includes just just two functions and some binary data.
Also there are two test R-scripts that I run after installing the R package with R CMD INSTALL goEnrichment. One test script fails while the other works.
The only difference between the two scripts is that in the working version I require the necessary libraries and source the functions file manually, while in the other failing script I require my goEnrichment library directly.
Note, that both scripts are started directly from their directory goEnrichment/exec.
Start the working test with cd goEnrichment/exec && Rscript testGoEnrichment_works.R. Excerpt:
# This is the WORKING version
require(GOstats)
require(GSEABase)
require(RMySQL)
source( "../R/goEnrichment.R" )
Start the failing test script with cd goEnrichment/exec && Rscript testGoEnrichment_fail.R. Excerpt:
# This version FAILS
require(goEnrichment)
The error I get is somewhat uninformative to me:
'dimnames' applied to non-array.
The built R package fails on two platforms, that is on Debian Wheezy 64 with R 3.0.2 and on Mac OS X Yosemite with R 3.1.1.
I really have no clue why this happens. I checked for file format and unexpected characters using Vim. The cause does not seem to be the DESCRIPTION file either, because all libraries, goEnrichment depends on, are imported.
Does any one have a clue what causes this very weird error? Help will be much appreciated.
After much testing I found the source of the problem.
For some reason when requiring my package with
require(goEnrichment)
the generic function
summary.GOHyperGResult
is not loaded, as it should be. The method however is available when the packages, goEnrichment depends upon, are required manually. As to why this is, I had no time to investigate. I believe the here reported error is related to this bug.
Thanks to Tyler for your efforts, very much!

Resources