Git Product home page Git Product logo

tensorflow's Introduction

TensorFlow for R

R build status CRAN_Status_Badge

TensorFlow™ is an open source software library for numerical computation using data flow graphs. Nodes in the graph represent mathematical operations, while the graph edges represent the multidimensional data arrays (tensors) communicated between them. The flexible architecture allows you to deploy computation to one or more CPUs or GPUs in a desktop, server, or mobile device with a single API.

The TensorFlow API is composed of a set of Python modules that enable constructing and executing TensorFlow graphs. The tensorflow package provides access to the complete TensorFlow API from within R.

Installation

To get started, install the tensorflow R package from GitHub as follows:

devtools::install_github("rstudio/tensorflow")

Then, use the install_tensorflow() function to install TensorFlow:

library(tensorflow)
install_tensorflow()

You can confirm that the installation succeeded with:

hello <- tf$constant("Hello")
print(hello)

This will provide you with a default installation of TensorFlow suitable for getting started with the tensorflow R package. See the article on installation to learn about more advanced options, including installing a version of TensorFlow that takes advantage of Nvidia GPUs if you have the correct CUDA libraries installed.

Documentation

See the package website for additional details on using the TensorFlow API from R: https://tensorflow.rstudio.com

See the TensorFlow API reference for details on all of the modules, classes, and functions within the API: https://www.tensorflow.org/api_docs/python/tf/all_symbols

The tensorflow package provides code completion and inline help for the TensorFlow API when running within the RStudio IDE. In order to take advantage of these features you should also install the Current Release of RStudio.

tensorflow's People

Contributors

alexanderbeatson avatar cortinah avatar danielmedinastacey avatar danklotz avatar dfalbel avatar eddelbuettel avatar fvd avatar goldingn avatar javierluraschi avatar jcrodriguez1989 avatar jimhester avatar jjallaire avatar jsta avatar kevinushey avatar kevinykuo avatar kmader avatar lorenzomoriconi avatar t-kalinowski avatar terrytangyuan avatar unrahul avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

tensorflow's Issues

Import/Installation Error

I installed the package at first with no issues, but when I tried loading it I get the following error:

ImportError: No module named tensorflow If you have not yet installed TensorFlow, see https://www.tensorflow.org/get_started/ Configuration: python: /usr/bin/python libpython: /usr/lib/python2.7/config-x86_64-linux-gnu/libpython2.7.so numpy: /usr/lib/python2.7/dist-packages/numpy/core/include

I am using python version 3.4, I don't need to change the python path, but I do need to change the paths to libpython and numpy. So I tried to reinstall using both:

Sys.setenv(TENSORFLOW_PYTHON="/usr/local/bin/python") devtools::install_github("rstudio/tensorflow")

and

Sys.setenv(TENSORFLOW_PYTHON=3) devtools::install_github("rstudio/tensorflow")

but I get the following error:

Downloading GitHub repo rstudio/tensorflow@master from URL https://api.github.com/repos/rstudio/tensorflow/zipball/master Installing tensorflow '/usr/lib/R/bin/R' --no-site-file --no-environ --no-save --no-restore --quiet CMD INSTALL \ '/tmp/RtmpPMSwtK/devtools28f3420d7dd8/rstudio-tensorflow-4c806d0' --library='/home/ahmedose/R/x86_64-pc-linux-gnu-library/3.3' --install-tests

installing *source* package ‘tensorflow’ ... Using python binary at 3.4 Using python version 3 Could not locate ERROR: configuration failed for package ‘tensorflow’

removing ‘/home/ahmedose/R/x86_64-pc-linux-gnu-library/3.3/tensorflow’

restoring previous ‘/home/ahmedose/R/x86_64-pc-linux-gnu-library/3.3/tensorflow’ Error: Command failed (1)

problem when loading tensorflow

Hi,
I have installed tensorflow following the first instruction. But it does not load when I run library(tensorflow).
see the informations below.

library("tensorflow", lib.loc="/R/x86_64-pc-linux-gnu-library/3.3")
Error in loadNamespace(j <- i[[1L]], c(lib.loc, .libPaths()), versionCheck = vI[[j]]) :
namespace ‘Rcpp’ 0.12.6 is already loaded, but >= 0.12.7 is required
Error: package or namespace load failed for ‘tensorflow’
library("Rcpp", lib.loc="
/R/x86_64-pc-linux-gnu-library/3.3")
Error in unloadNamespace(package) :
namespace ‘Rcpp’ is imported by ‘scales’, ‘plyr’ so cannot be unloaded
Error in library("Rcpp", lib.loc = "~/R/x86_64-pc-linux-gnu-library/3.3") :
Package ‘Rcpp’ version 0.12.6 cannot be unloaded
sessionInfo()
R version 3.3.1 (2016-06-21)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 14.04.5 LTS

locale:
[1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C LC_TIME=en_US.UTF-8 LC_COLLATE=en_US.UTF-8 LC_MONETARY=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8
[7] LC_PAPER=en_US.UTF-8 LC_NAME=C LC_ADDRESS=C LC_TELEPHONE=C LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C

attached base packages:
[1] datasets utils stats graphics grDevices methods base

other attached packages:
[1] ggplot2_2.1.0 stringi_1.1.1 opal_2.2.10 rjson_0.2.15 RCurl_1.95-4.8 bitops_1.0-6 data.table_1.9.6 magrittr_1.5 MASS_7.3-44

loaded via a namespace (and not attached):
[1] Rcpp_0.12.7 knitr_1.13 devtools_1.12.0 munsell_0.4.3 colorspace_1.2-6 R6_2.1.2 httr_1.2.1 plyr_1.8.4 tools_3.3.1
[10] grid_3.3.1 gtable_0.2.0 git2r_0.15.0 withr_1.0.2 digest_0.6.9 curl_1.1 memoise_1.0.0 scales_0.4.0 chron_2.3-47

Thanks

Passing lists of tensors as arguments

Hi all

Some tf functions expect a Python list of Tensors as an argument, e.g. tf.concat() and tf.pack(). Is there any elegant way to pass an R list of tensors to these functions? Simply using tf$concat(concat_dim = 1, values = list(t1, t2), name = "concat1") throws an error - I believe because the Tensors are passed as a tuple instead of a list.

I'm currently using the following (admittedly ugly) workaround:

tf_concatenate <- function(tf, concat_dim, t1, t2, name) {
  tensorflow:::py_run_string("def tfcc(tf, concat_dim, t1, t2, name):
    return tf.concat(concat_dim, [t1, t2], name)")
  mn <- tensorflow::import("__main__")
  mn$tfcc(tf, as.integer(concat_dim), t1, t2, name)
}

Cannot install: package fails to load

When installing via `devtools::install_github('rstudio/tensorflow'), the compilation proceeds correctly, but then I receive the following error:

> devtools::install_github('rstudio/tensorflow')
Downloading GitHub repo rstudio/tensorflow@master

<snip>

installing to /home/alex/.local/opt/R/x86_64-pc-linux-gnu-library/3.3/tensorflow/libs
** R
** inst
** tests
** preparing package for lazy loading
** help
*** installing help indices
** building package indices
** testing if installed package can be loaded
Error : .onLoad failed in loadNamespace() for 'tensorflow', details:
  call: system(paste(shQuote(python), shQuote(system.file("config/config.py", 
  error: error in running command
Error: loading failed
Execution halted
ERROR: loading failed
* removing ‘/home/alex/.local/opt/R/x86_64-pc-linux-gnu-library/3.3/tensorflow’
Error: Command failed (1)

As can be seen above, I am using R 3.3, and have TensorFlow 0.12 installed with my system python version (3.5).

tf$concat behave differently compared to Python TF

I have two pieces of code. The first one in Python with tf:

a = tf.Variable(np.array([[0.33, 0.33, 0.33]]), dtype = tf.float32)
b = tf.Variable(np.array([[0.11, 0.22, 0.33], [0.44, 0.55, 0.66]]), dtype = tf.float32)
tf.concat(0, [a, b])

This works fine. Now the second one in Rstudio tensorflow package:

a = tf$Variable(matrix(c(0.33,0.33,0.33), nrow = 1), dtype = tf$float32)
b = tf$Variable(matrix(c(0.11, 0.22, 0.33, 0.44, 0.55, 0.66), nrow = 2), dtype = tf$float32)
tf$concat(0, list(a,b))

This results in the error: Error in py_call(attrib, args, keywords) : basic_string::resize
Could you help figure out why this happens? Also, could the error message be more specific, instead of being all the same? Thanks in advance!

extract syntax for variables

Looks like I forgot to export the extract syntax for variables, so this works:

library(tensorflow)
x <- tf$constant(array(0, dim = c(2, 2)))
x[, 1]
Tensor("StridedSlice:0", shape=(2,), dtype=float64)

but this doesn't:

z <- tf$Variable(array(0, dim = c(2, 2)))
z[, 1]
Error in z[, 1] : object of type 'externalptr' is not subsettable

PR coming soon

Close but no cigar

tensorflow itself

Installed fine, running demo now:

[...]
Step 2200 (epoch 2.56), 217.7 ms
Minibatch loss: 2.575, learning rate: 0.009025
Minibatch error: 0.0%
Validation error: 1.2%
Step 2300 (epoch 2.68), 221.4 ms
Minibatch loss: 2.554, learning rate: 0.009025
Minibatch error: 1.6%
Validation error: 1.1%
Step 2400 (epoch 2.79), 224.7 ms
Minibatch loss: 2.502, learning rate: 0.009025
Minibatch error: 0.0%
Validation error: 1.1%
[...]

R package almost gets there

edd@brad:~/git/tensorflow(master)$ R CMD INSTALL .
* installing to library/usr/local/lib/R/site-library* installing *source* packagetensorflow...
Using system version of python
checking for gcc... ccache gcc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables... 
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether ccache gcc accepts -g... yes
checking for ccache gcc option to accept ISO C89... none needed
configure: creating ./config.status
config.status: creating src/Makevars
** libs
ccache g++ -I/usr/share/R/include -DNDEBUG -I/usr/include/python2.7 -I/usr/include/x86_64-linux-gnu/pytho
n2.7 -I/usr/local/lib/python2.7/dist-packages/numpy/core/include -D PYTHONLIBFILE=libpython2.7.so  -I"/us
r/local/lib/R/site-library/Rcpp/include"   -fpic  -g -O3 -Wall -pipe -Wno-unused -pedantic -c RcppExports
.cpp -o RcppExports.o
In file included from /usr/include/python2.7/Python.h:86:0,
                 from tensorflow_types.hpp:1,
                 from RcppExports.cpp:4:
/usr/include/python2.7/intobject.h:46:15: warning: ISO C++ 1998 does not supportlong long’ [-Wlong-long
]
 PyAPI_FUNC(unsigned PY_LONG_LONG) PyInt_AsUnsignedLongLongMask(PyObject *);
               ^
[....]
/usr/include/python2.7/longobject.h:53:15: warning: ISO C++ 1998 does not supportlong long’ [-Wlong-long]
 PyAPI_FUNC(unsigned PY_LONG_LONG) PyLong_AsUnsignedLongLong(PyObject *);
               ^
/usr/include/python2.7/longobject.h:54:15: warning: ISO C++ 1998 does not supportlong long’ [-Wlong-long]
 PyAPI_FUNC(unsigned PY_LONG_LONG) PyLong_AsUnsignedLongLongMask(PyObject *);
               ^
/usr/include/python2.7/longobject.h:55:6: warning: ISO C++ 1998 does not supportlong long’ [-Wlong-long]
 PyAPI_FUNC(PY_LONG_LONG) PyLong_AsLongLongAndOverflow(PyObject *, int *);
      ^
In file included from /usr/local/lib/python2.7/dist-packages/numpy/core/include/numpy/ndarraytypes.h:4:0,
                 from /usr/local/lib/python2.7/dist-packages/numpy/core/include/numpy/ndarrayobject.h:18,
                 from /usr/local/lib/python2.7/dist-packages/numpy/core/include/numpy/arrayobject.h:4,
                 from python.cpp:2:
/usr/local/lib/python2.7/dist-packages/numpy/core/include/numpy/npy_common.h:281:14: warning: ISO C++ 1998 does not supportlong long’ [-Wlong-long]
 typedef PY_LONG_LONG npy_longlong;
              ^
/usr/local/lib/python2.7/dist-packages/numpy/core/include/numpy/npy_common.h:282:23: warning: ISO C++ 1998 does not supportlong long’ [-Wlong-long]
 typedef unsigned PY_LONG_LONG npy_ulonglong;
                       ^
g++ -shared -L/usr/lib/R/lib -Wl,-Bsymbolic-functions -Wl,-z,relro -o tensorflow.so RcppExports.o python.o -L/usr/lib/python2.7/config-x86_64-linux-gnu -L/usr/lib -lpython2.7 -lpthread -ldl -lutil -lm -Xlinker -export-dynamic -Wl,-O1 -Wl,-Bsymbolic-functions -L/usr/lib/R/lib -lR
installing to /usr/local/lib/R/site-library/tensorflow/libs
** R
** inst
** preparing package for lazy loading
** help
*** installing help indices
** building package indices
** testing if installed package can be loaded
ImportError: numpy.core.multiarray failed to import
Error : .onLoad failed in loadNamespace() for 'tensorflow', details:
  call: NULL
  error: numpy.core.multiarray failed to import
Error: loading failed
Execution halted
ERROR: loading failed
* removing/usr/local/lib/R/site-library/tensorflowedd@brad:~/git/tensorflow(master)$ 

I checked and I only have one set of numpy libs -- the ones I got from tf.

edd@brad:~/git/tensorflow(master)$ python
Python 2.7.12 (default, Jul  1 2016, 15:12:24) 
[GCC 5.4.0 20160609] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import numpy as np
>>> 

Thoughts?

Deep MNIST for Experts: Error

When running this example from the RStudio site, I was getting an error message:

Error in py_call(attrib, args, keywords) :
ValueError: Cannot execute operation using run(): No default session is registered. Use with sess.as_default(): or pass an explicit session to run(session=sess)

The fix is to change the following lines:

train_accuracy <- accuracy$eval(feed_dict = dict(
x = batch[[1]], y_ = batch[[2]], keep_prob = 1.0))
train_step$run(feed_dict = dict(
x = batch[[1]], y_ = batch[[2]], keep_prob = 0.5))
train_accuracy <- accuracy$eval(feed_dict = dict(
x = mnist$test$images, y_ = mnist$test$labels, keep_prob = 1.0))

for these ones:

train_accuracy <- accuracy$eval(session=sess, feed_dict = dict(
x = batch[[1]], y_ = batch[[2]], keep_prob = 1.0))
train_step$run(session=sess, feed_dict = dict(
x = batch[[1]], y_ = batch[[2]], keep_prob = 0.5))
train_accuracy <- accuracy$eval(session=sess, feed_dict = dict(
x = mnist$test$images, y_ = mnist$test$labels, keep_prob = 1.0))

Best,
Axel.

R Crashes when loading tensorflow with latest 3.3.2 version

Hello,
I don't know if this has been reported yet, but i haven't seen any open issue relative to that (might be more an RStudio issue).

I was using microsoft R 3.3.1 with RStudio 1.0.44 and tensorflow was working like a charm (great job porting it to R btw!).

I switched to 3.3.2 and now, when I load tensorflow with library(tensorflow) (even on a clean session), the R session crashes (R Session Aborted message) and have to be restarted.

Here are my systems info:

R version 3.3.2 (2016-10-31)
Platform: x86_64-apple-darwin13.4.0 (64-bit)
Running under: OS X El Capitan 10.11.6

locale:
[1] en_GB.UTF-8/en_GB.UTF-8/en_GB.UTF-8/C/en_GB.UTF-8/en_GB.UTF-8

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

loaded via a namespace (and not attached):
[1] tools_3.3.2

Thanks for your time!

installation issue with Anaconda on Mac

I'm so excited to have an R interface. Thanks so much for building this.

Unfortunately, it doesn't seem to work on my machine yet. After what seems like a successful install (see installation messages at the bottom of this post), I get the following message when I try to load it in RStudio:

>library(tensorflow)
TensorFlow not currently installed, please see https://www.tensorflow.org/get_started/

My best guess is that it's an Anaconda issue? Here's what I get when I type python at the bash prompt:

Python 2.7.11 |Anaconda 2.4.0 (x86_64)| (default, Dec  6 2015, 18:57:58) 
[GCC 4.2.1 (Apple Inc. build 5577)] on darwin

Tensorflow works from Python (I've used it via the keras package). I've copied its location in my file directory below:

>>> import tensorflow as tf
>>> tf
<module 'tensorflow' from '/Users/davidharris/anaconda/lib/python2.7/site-packages/tensorflow/__init__.pyc'>

Let me know if I can provide any additional information that would help debug this. Thanks again!

session_info:

setting  value                       
 version  R version 3.3.1 (2016-06-21)
 system   x86_64, darwin13.4.0        
 ui       RStudio (1.0.27)            
 language (EN)                        
 collate  en_US.UTF-8                 
 tz       America/New_York            
 date     2016-09-28                  

Packages --------------------------------------------------------------------------------
 package    * version date       source                             
 curl         2.1     2016-09-22 CRAN (R 3.3.0)                     
 devtools   * 1.12.0  2016-06-24 CRAN (R 3.3.0)                     
 digest       0.6.10  2016-08-02 cran (@0.6.10)                     
 git2r        0.15.0  2016-05-11 CRAN (R 3.3.0)                     
 httr         1.2.1   2016-07-03 CRAN (R 3.3.0)                     
 memoise      1.0.0   2016-01-29 CRAN (R 3.3.0)                     
 R6           2.1.3   2016-08-19 cran (@2.1.3)                      
 Rcpp         0.12.7  2016-09-05 CRAN (R 3.3.0)                     
 tensorflow * 0.3.0   2016-09-28 Github (rstudio/tensorflow@3fe7912)
 withr        1.0.2   2016-06-20 CRAN (R 3.3.0)                     

Installation messages:

install_github("rstudio/tensorflow", force = TRUE)
Downloading GitHub repo rstudio/tensorflow@master
from URL https://api.github.com/repos/rstudio/tensorflow/zipball/master
Installing tensorflow
'/Library/Frameworks/R.framework/Resources/bin/R' --no-site-file --no-environ  \
  --no-save --no-restore --quiet CMD INSTALL  \
  '/private/var/folders/fw/mq81111s0kvckgx47x8z5n380000gn/T/RtmpoYxlP6/devtools69a17ee28734/rstudio-tensorflow-3fe7912'  \
  --library='/Library/Frameworks/R.framework/Versions/3.3/Resources/library'  \
  --install-tests 

* installing *source* package ‘tensorflow’ ...
Using system version of python
checking for gcc... clang
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables... 
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether clang accepts -g... yes
checking for clang option to accept ISO C89... none needed
configure: creating ./config.status
config.status: creating src/Makevars
config.status: creating R/config.R
** libs
clang++ -std=c++11 -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG -I/System/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7 -I/System/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7 -I/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/numpy/core/include -D PYTHONLIBFILE=libpython2.7.so -I/usr/local/include -I/usr/local/include/freetype2 -I/opt/X11/include -I"/Library/Frameworks/R.framework/Versions/3.3/Resources/library/Rcpp/include"   -fPIC  -Wall -mtune=core2 -g -O2 -c RcppExports.cpp -o RcppExports.o
clang++ -std=c++11 -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG -I/System/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7 -I/System/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7 -I/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/numpy/core/include -D PYTHONLIBFILE=libpython2.7.so -I/usr/local/include -I/usr/local/include/freetype2 -I/opt/X11/include -I"/Library/Frameworks/R.framework/Versions/3.3/Resources/library/Rcpp/include"   -fPIC  -Wall -mtune=core2 -g -O2 -c python.cpp -o python.o
clang++ -std=c++11 -dynamiclib -Wl,-headerpad_max_install_names -undefined dynamic_lookup -single_module -multiply_defined suppress -L/Library/Frameworks/R.framework/Resources/lib -L/usr/local/lib -o tensorflow.so RcppExports.o python.o -L/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/config -lpython2.7 -ldl -framework CoreFoundation -F/Library/Frameworks/R.framework/.. -framework R -Wl,-framework -Wl,CoreFoundation
installing to /Library/Frameworks/R.framework/Versions/3.3/Resources/library/tensorflow/libs
** R
** inst
** tests
** preparing package for lazy loading
** help
*** installing help indices
** building package indices
** testing if installed package can be loaded
* DONE (tensorflow)

ImportError: No module named tensorflow

R tensorflow installation goes fine, but attaching the package gives an error (as shown below). TensorFlow was installed using Pip and, as indicated below, tests show no issues.

Sys.setenv(TENSORFLOW_PYTHON="/usr/local/bin/python")
devtools::install_github("rstudio/tensorflow")
installing to /Library/Frameworks/R.framework/Versions/3.3/Resources/library/tensorflow/libs
** R
** inst
** tests
** preparing package for lazy loading
** help
*** installing help indices
** building package indices
** testing if installed package can be loaded

  • DONE (tensorflow)

library(tensorflow)
ImportError: No module named tensorflow
If you have not yet installed TensorFlow, see https://www.tensorflow.org/get_started/
Configuration:
python: /usr/local/bin/python
libpython: /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/config/libpython2.7.dylib
numpy: /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/numpy/core/include

sessionInfo()
R version 3.3.0 (2016-05-03)
Platform: x86_64-apple-darwin13.4.0 (64-bit)
Running under: OS X 10.11.6 (El Capitan)

locale:
[1] en_CA.UTF-8/en_CA.UTF-8/en_CA.UTF-8/C/en_CA.UTF-8/en_CA.UTF-8

attached base packages:
[1] stats graphics grDevices utils datasets methods base

other attached packages:
[1] tensorflow_0.3.0

loaded via a namespace (and not attached):
[1] httr_1.1.0 R6_2.2.0 tools_3.3.0 withr_1.0.2 curl_2.1 Rcpp_0.12.7
[7] memoise_1.0.0 digest_0.6.10 devtools_1.11.1

From command line (installation test goes fine)

$ python
...

import tensorflow as tf
hello = tf.constant('Hello, TensorFlow!')
sess = tf.Session()
print(sess.run(hello))
Hello, TensorFlow!

ERROR: dependency 'Rcpp' is not available for package 'tensorflow'

Report Rcpp not available while I already installed it.

library(Rcpp)
devtools::install_github("rstudio/tensorflow")
Downloading GitHub repo rstudio/tensorflow@master
from URL https://api.github.com/repos/rstudio/tensorflow/zipball/master
Installing tensorflow
"C:/PROGRA1/R/R-331.2/bin/x64/R" --no-site-file --no-environ --no-save --no-restore --quiet CMD
INSTALL
"C:/Users/wahol/AppData/Local/Temp/Rtmpiwg3qe/devtools53c453d76ce/rstudio-tensorflow-e91f28f"
--library="C:/Users/wahol/OneDrive/文档/R/win-library/3.3" --install-tests

ERROR: dependency 'Rcpp' is not available for package 'tensorflow'

  • removing 'C:/Users/wahol/OneDrive/文档/R/win-library/3.3/tensorflow'
    Error: Command failed (1)

ImportError: No module named tensorflow

Sorry if I'm making a stupid mistake here (but I don't see which it could be) - I have a problem that looks similar to an already closed issue (#24)

I've created a virtualenv with my system python, which is python 2.7 (in order not to use any of my existing conda envs), and I have the following:

Sys.setenv(TENSORFLOW_PYTHON="/home/key/tensorflow/bin/python")
devtools::install_github("rstudio/tensorflow", force=TRUE)
Downloading GitHub repo rstudio/tensorflow@master
from URL https://api.github.com/repos/rstudio/tensorflow/zipball/master
Installing tensorflow
'/usr/lib64/R/bin/R' --no-site-file --no-environ --no-save --no-restore --quiet CMD INSTALL
'/tmp/Rtmp3Ocl57/devtools30276a92640/rstudio-tensorflow-dfe2f1a'
--library='/home/key/R/x86_64-redhat-linux-gnu-library/3.3' --install-tests

  • installing source package ‘tensorflow’ ...
    Using python binary at /home/key/tensorflow/bin/python
    ...
    ...
    ** building package indices
    ** testing if installed package can be loaded
  • DONE (tensorflow)
    Reloading installed tensorflow
    ImportError: No module named tensorflow
    If you have not yet installed TensorFlow, see https://www.tensorflow.org/get_started/
    Configuration:
    python: /home/key/tensorflow/bin/python
    libpython: libpython2.7.so
    numpy: /home/key/tensorflow/lib/python2.7/site-packages/numpy/core/include

Would be great if you could help!
Many thanks
Sigrid

Installation fails with Microsoft R 3.3.2 (Ubuntu)

tl;dr add CXX1X=gcc -std=c++0x and CXX1XSTD=-std=c++0x -fPIC to the Makeconf file.

This may not be an issue with this package, but I haven't run into this before. Installation worked on the same system with the CRAN install so it's probably not related to missing tools. I'm curious if anyone else had this issue.

Installation failed for me using the following commands...

Sys.setenv(TENSORFLOW_PYTHON="/usr/bin/python")
Sys.setenv(TENSORFLOW_PYTHON_VERSION = 3)
devtools::install_github("rstudio/tensorflow")

... with the following error...

* installing *source* package ‘tensorflow’ ...
Using python binary at /usr/bin/python
Using python version 3
checking for gcc... gcc -std=gnu99
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables... 
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc -std=gnu99 accepts -g... yes
checking for gcc -std=gnu99 option to accept ISO C89... none needed
configure: creating ./config.status
config.status: creating src/Makevars
config.status: creating R/config.R
** libs
I/usr/lib64/microsoft-r/3.3/lib64/R/include -DNDEBUG -I/usr/include/python3.5m -I/usr/include/python3.5m -I/usr/local/lib/python3.5/dist-packages/numpy/core/include -D PYTHONLIBFILE=libpython3.5.so -DU_STATIC_IMPLEMENTATION -I"/home/xps/R/x86_64-pc-linux-gnu-library/3.3/Rcpp/include"      -c RcppExports.cpp -o RcppExports.o
sh: I/usr/lib64/microsoft-r/3.3/lib64/R/include: No such file or directory
/usr/lib64/microsoft-r/3.3/lib64/R/etc/Makeconf:141: recipe for target 'RcppExports.o' failed
make: [RcppExports.o] Error 127 (ignored)
I/usr/lib64/microsoft-r/3.3/lib64/R/include -DNDEBUG -I/usr/include/python3.5m -I/usr/include/python3.5m -I/usr/local/lib/python3.5/dist-packages/numpy/core/include -D PYTHONLIBFILE=libpython3.5.so -DU_STATIC_IMPLEMENTATION -I"/home/xps/R/x86_64-pc-linux-gnu-library/3.3/Rcpp/include"      -c python.cpp -o python.o
sh: I/usr/lib64/microsoft-r/3.3/lib64/R/include: No such file or directory
/usr/lib64/microsoft-r/3.3/lib64/R/etc/Makeconf:141: recipe for target 'python.o' failed
make: [python.o] Error 127 (ignored)
-shared -L/usr/lib64/microsoft-r/3.3/lib64/R/lib -o tensorflow.so RcppExports.o python.o -L/usr/lib/python3.5/config-3.5m-x86_64-linux-gnu -L/usr/lib -lpython3.5m -lpthread -ldl -lutil -lm -Xlinker -export-dynamic -Wl,-O1 -Wl,-Bsymbolic-functions -L/usr/lib64/microsoft-r/3.3/lib64/R/lib -lR
sh: line 2: -shared: command not found
/usr/lib64/microsoft-r/3.3/lib64/R/share/make/shlib.mk:6: recipe for target 'tensorflow.so' failed

Adding these flags to my Makeconf allowed the installation to complete.
/usr/lib64/microsoft-r/3.3/lib64/R/etc/Makeconf

CXX1X=gcc -std=c++0x
CXX1XSTD=-std=c++0x -fPIC

Quick test...

> library(tensorflow)
> sess = tf$Session()
> a = tf$constant(6)
> b = tf$constant(4)
> sess$run(a*b)
[1] 24

My system:

> sessionInfo()
R version 3.3.2 (2016-10-31)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 16.04.1 LTS

locale:
 [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C               LC_TIME=en_US.UTF-8        LC_COLLATE=en_US.UTF-8     LC_MONETARY=en_US.UTF-8   
 [6] LC_MESSAGES=en_US.UTF-8    LC_PAPER=en_US.UTF-8       LC_NAME=C                  LC_ADDRESS=C               LC_TELEPHONE=C            
[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C       

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] Rcpp_0.12.7          devtools_1.12.0      RevoUtilsMath_10.0.0

loaded via a namespace (and not attached):
 [1] httr_1.2.0        R6_2.1.2          RevoUtils_10.0.2  tools_3.3.2       withr_1.0.2       rstudioapi_0.6    curl_0.9.7        memoise_1.0.0    
 [9] git2r_0.15.0.9000 digest_0.6.9     

python3 error in ‘Py_InitModule’

I tried to install your tensorflow package with python 3 (Ubuntu xenial, R 3.2.3) and got some compile error in Py_InitModule. It seems this function is deprecated in Python 3.

Sys.setenv(TENSORFLOW_PYTHON_VERSION = 3)
devtools::install_github("rstudio/tensorflow")

g++ -std=c++11 -I/usr/share/R/include -DNDEBUG -I/usr/include/python3.5m -I/usr/include/python3.5m -I/usr/local/lib/python3.5/dist-packages/numpy/core/include -D PYTHONLIBFILE=libpython3.5.so -I"/home/kwee/R/x86_64-pc-linux-gnu-library/3.2/Rcpp/include" -fpic -g -O2 -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g -c python.cpp -o python.o python.cpp: In function ‘void py_initialize(const string&)’: python.cpp:896:40: error: ‘Py_InitModule’ was not declared in this scope Py_InitModule("tfcall", TFCallMethods);

Cannot access certain module via `$`

This doesn't work:

> tf$python$framework
Error in py_get_attr(x, name) : 
  AttributeError: 'module' object has no attribute 'framework'

The following works:

> import("tensorflow.python.framework")
Module(tensorflow.python.framework)

Eliminate deprecation warnings in tf.learn examples

There are currently lots of deprecation warnings in the tflearn examples. Let's modify this code to use whatever the most up to date idioms are. Note that I've made the minimum required version of TF 0.12 via 5274628 if that helps.

Note also that I removed all the other warnings (mostly due to the tf$summary migration) here: 993974e

@terrytangyuan

Fail in py_config() call

Nice working making tf available from R interface :D

I'm having a small problem when trying to install:
devtools::install_github("rstudio/tensorflow")
I get:

Error : .onLoad failed in loadNamespace() for 'tensorflow', details:
  call: py_config()
  error: Unable to parse -L from -lpython2.7 -lpthread -ldl -lutil -lm -Xlinker -export-dynamic
Error: loading failed
Execution halted

I believe it has to do with g++ compiling the package in:

g++ -std=c++11 -shared -L/home/pingfreud/anaconda3/lib/R/lib -L/home/pingfreud/anaconda3/lib -lgfortran -o tensorflow.so RcppExports.o python.o -lpython2.7 -lpthread -ldl -lutil -lm -Xlinker -export-dynamic -L/home/pingfreud/anaconda3/lib/R/lib -lR

I installed tf using:

export TF_BINARY_URL=https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow-0.11.0rc0-cp27-none-linux_x86_64.whl
sudo pip install --upgrade $TF_BINARY_URL

Tf is working normally when called from python2.7.

I tried setting TENSORFLOW_PYTHON directly to /usr/bin/python2.7 and also setting TENSORFLOW_PYTHON_VERSION to 2.7 but I still get the same error message.

Type Error with tf$contrib$layers$bucketized_column

I'm working on an R version of the Tensorflow Linear Model tutorial.

I can create the age column, but when I attempt to bucket it, I receive the following error:

`
age <- tf$contrib$layers$real_valued_column("age")

age_buckets <- tf$contrib$layers$bucketized_column(age, boundaries = c(18, 25, 30, 35, 40, 45, 50, 55, 60, 65))
`

Error in eval(substitute(expr), envir, enclos) :
TypeError: source_column must be an instance of _RealValuedColumn. source_column: {'default_value': None, 'dtype': tf.float32, 'dimension': 1, 'column_name': 'age'}

Compilation error on OSX

Sys.setenv(TENSORFLOW_PYTHON_VERSION = 3)
devtools::install_github("rstudio/tensorflow")

I receive the following error:

Downloading GitHub repo rstudio/tensorflow@master
from URL https://api.github.com/repos/rstudio/tensorflow/zipball/master
Installing tensorflow
'/usr/local/Cellar/r/3.3.1_2/R.framework/Resources/bin/R' --no-site-file  \
  --no-environ --no-save --no-restore --quiet CMD INSTALL  \
  '/private/var/folders/cv/b7g24y7d3vb167gvnh_p694w0000gn/T/Rtmp4XJDlR/devtoolsea5a1f09d8a6/rstudio-tensorflow-87c96b3'  \
  --library='/usr/local/lib/R/3.3/site-library' --install-tests

* installing *source* package ‘tensorflow’ ...
Using python version 3
checking for gcc... /usr/local/Cellar/gcc/6.2.0/bin/gcc-6
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables...
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether /usr/local/Cellar/gcc/6.2.0/bin/gcc-6 accepts -g... yes
checking for /usr/local/Cellar/gcc/6.2.0/bin/gcc-6 option to accept ISO C89... none needed
configure: creating ./config.status
config.status: creating src/Makevars
config.status: creating R/config.R
** libs
clang++ -std=c++11 -I/usr/local/Cellar/r/3.3.1_2/R.framework/Resources/include -DNDEBUG -I/usr/local/Cellar/python3/3.5.2_1/Frameworks/Python.framework/Versions/3.5/include/python3.5m -I/usr/local/Cellar/python3/3.5.2_1/Frameworks/Python.framework/Versions/3.5/include/python3.5m -I/usr/local/lib/python3.5/site-packages/numpy/core/include -D PYTHONLIBFILE=libpython3.5.so -I/usr/local/opt/gettext/include -I/usr/local/opt/readline/include -I/usr/local/opt/openssl/include -I/usr/local/include -I"/usr/local/lib/R/3.3/site-library/Rcpp/include"   -fPIC  -g -O2 -c RcppExports.cpp -o RcppExports.o
clang++ -std=c++11 -I/usr/local/Cellar/r/3.3.1_2/R.framework/Resources/include -DNDEBUG -I/usr/local/Cellar/python3/3.5.2_1/Frameworks/Python.framework/Versions/3.5/include/python3.5m -I/usr/local/Cellar/python3/3.5.2_1/Frameworks/Python.framework/Versions/3.5/include/python3.5m -I/usr/local/lib/python3.5/site-packages/numpy/core/include -D PYTHONLIBFILE=libpython3.5.so -I/usr/local/opt/gettext/include -I/usr/local/opt/readline/include -I/usr/local/opt/openssl/include -I/usr/local/include -I"/usr/local/lib/R/3.3/site-library/Rcpp/include"   -fPIC  -g -O2 -c python.cpp -o python.o
clang++ -std=c++11 -dynamiclib -Wl,-headerpad_max_install_names -undefined dynamic_lookup -single_module -multiply_defined suppress -L/usr/local/opt/gettext/lib -L/usr/local/opt/readline/lib -L/usr/local/opt/openssl/lib -L/usr/local/lib -L/usr/local/Cellar/r/3.3.1_2/R.framework/Resources/lib -L/usr/local/opt/gettext/lib -L/usr/local/opt/readline/lib -L/usr/local/opt/openssl/lib -L/usr/local/lib -o tensorflow.so RcppExports.o python.o -L/usr/local/Cellar/python3/3.5.2_1/Frameworks/Python.framework/Versions/3.5/lib/python3.5/config-3.5m -lpython3.5m -ldl -framework CoreFoundation -L/usr/local/lib -F/usr/local/Cellar/r/3.3.1_2/R.framework/.. -framework R -lintl -Wl,-framework -Wl,CoreFoundation
installing to /usr/local/lib/R/3.3/site-library/tensorflow/libs
** R
** inst
** tests
** preparing package for lazy loading
** help
*** installing help indices
** building package indices
** testing if installed package can be loaded
sh: line 1: 61050 Segmentation fault: 11  '/usr/local/Cellar/r/3.3.1_2/R.framework/Resources/bin/R' --no-save --slave 2>&1 < '/var/folders/cv/b7g24y7d3vb167gvnh_p694w0000gn/T//RtmpbTwuqF/fileec833c48f1e0'

 *** caught segfault ***
address 0x0, cause 'unknown'

Traceback:
 1: .Call("tensorflow_py_module_impl", PACKAGE = "tensorflow", module)
 2: py_module_impl(module)
 3: doTryCatch(return(expr), name, parentenv, handler)
 4: tryCatchOne(expr, names, parentenv, handlers[[1L]])
 5: tryCatchList(expr, classes, parentenv, handlers)
 6: tryCatch(py_module_impl(module), error = function(e) NULL)
 7: import("tensorflow", silent = TRUE)
 8: tf_on_load(libname, pkgname)
 9: fun(libname, pkgname)
10: doTryCatch(return(expr), name, parentenv, handler)
11: tryCatchOne(expr, names, parentenv, handlers[[1L]])
12: tryCatchList(expr, classes, parentenv, handlers)
13: tryCatch(fun(libname, pkgname), error = identity)
14: runHook(".onLoad", env, package.lib, package)
15: loadNamespace(package, lib.loc)
16: doTryCatch(return(expr), name, parentenv, handler)
17: tryCatchOne(expr, names, parentenv, handlers[[1L]])
18: tryCatchList(expr, classes, parentenv, handlers)
19: tryCatch(expr, error = function(e) {    call <- conditionCall(e)    if (!is.null(call)) {        if (identical(call[[1L]], quote(doTryCatch)))             call <- sys.call(-4L)  dcall <- deparse(call)[1L]        prefix <- paste("Error in", dcall, ": ")        LONG <- 75L        msg <- conditionMessage(e)        sm <- strsplit(msg, "\n")[[1L]]        w <- 14L + nchar(dcall, type = "w") + nchar(sm[1L], type = "w")        if (is.na(w))             w <- 14L + nchar(dcall, type = "b") + nchar(sm[1L],                 type = "b")        if (w > LONG)             prefix <- paste0(prefix, "\n  ")    }    else prefix <- "Error : "    msg <- paste0(prefix, conditionMessage(e), "\n")    .Internal(seterrmessage(msg[1L]))    if (!silent && identical(getOption("show.error.messages"),         TRUE)) {        cat(msg, file = stderr())        .Internal(printDeferredWarnings())    }    invisible(structure(msg, class = "try-error", condition = e))})
20: try({    attr(package, "LibPath") <- which.lib.loc    ns <- loadNamespace(package, lib.loc)    env <- attachNamespace(ns, pos = pos, deps)})
21: library(pkg_name, lib.loc = lib, character.only = TRUE, logical.return = TRUE)
22: withCallingHandlers(expr, packageStartupMessage = function(c) invokeRestart("muffleMessage"))
23: suppressPackageStartupMessages(library(pkg_name, lib.loc = lib,     character.only = TRUE, logical.return = TRUE))
24: doTryCatch(return(expr), name, parentenv, handler)
25: tryCatchOne(expr, names, parentenv, handlers[[1L]])
26: tryCatchList(expr, classes, parentenv, handlers)
27: tryCatch(expr, error = function(e) {    call <- conditionCall(e)    if (!is.null(call)) {        if (identical(call[[1L]], quote(doTryCatch)))             call <- sys.call(-4L)  dcall <- deparse(call)[1L]        prefix <- paste("Error in", dcall, ": ")        LONG <- 75L        msg <- conditionMessage(e)        sm <- strsplit(msg, "\n")[[1L]]        w <- 14L + nchar(dcall, type = "w") + nchar(sm[1L], type = "w")        if (is.na(w))             w <- 14L + nchar(dcall, type = "b") + nchar(sm[1L],                 type = "b")        if (w > LONG)             prefix <- paste0(prefix, "\n  ")    }    else prefix <- "Error : "    msg <- paste0(prefix, conditionMessage(e), "\n")    .Internal(seterrmessage(msg[1L]))    if (!silent && identical(getOption("show.error.messages"),         TRUE)) {        cat(msg, file = stderr())        .Internal(printDeferredWarnings())    }    invisible(structure(msg, class = "try-error", condition = e))})
28: try(suppressPackageStartupMessages(library(pkg_name, lib.loc = lib,     character.only =TRUE, logical.return = TRUE)))
29: tools:::.test_load_package("tensorflow", "/usr/local/lib/R/3.3/site-library")
An irrecoverable exception occurred. R is aborting now ...
ERROR: loading failed
* removing ‘/usr/local/lib/R/3.3/site-library/tensorflow
Sys.info()
sysname
"Darwin"
release
"16.0.0"
version
"Darwin Kernel Version 16.0.0: Mon Aug 29 17:56:20 PDT 2016; root:xnu-3789.1.32~3/RELEASE_X86_64"
machine
"x86_64"
 R.Version()
$platform
[1] "x86_64-apple-darwin15.5.0"

$arch
[1] "x86_64"

$os
[1] "darwin15.5.0"

$system
[1] "x86_64, darwin15.5.0"

$status
[1] ""

$major
[1] "3"

$minor
[1] "3.1"

$year
[1] "2016"

$month
[1] "06"

$day
[1] "21"

$`svn rev`
[1] "70800"

$language
[1] "R"

$version.string
[1] "R version 3.3.1 (2016-06-21)"

$nickname
[1] "Bug in Your Hair"

ERROR: compilation failed for package 'tensorflow'

c:/Rtools/mingw_32/bin/g++ -I"C:/PROGRA1/R/R-331.2/include" -DNDEBUG -I"C:/Users/rocket/Documents/R/win-library/3.3/Rcpp/include" -I"d:/Compiler/gcc-4.9.3/local330/include" -O2 -Wall -mtune=core2 -c RcppExports.cpp -o RcppExports.o
In file included from RcppExports.cpp:4:0:
tensorflow_types.hpp:1:20: fatal error: Python.h: No such file or directory
#include <Python.h>
^
compilation terminated.
make: *** [RcppExports.o] Error 1
Warning: 运行命令'make -f "C:/PROGRA1/R/R-331.2/etc/i386/Makeconf" -f "C:/PROGRA1/R/R-331.2/share/make/winshlib.mk" SHLIB_LDFLAGS='$(SHLIB_CXXLDFLAGS)' SHLIB_LD='$(SHLIB_CXXLD)' SHLIB="tensorflow.dll" OBJECTS="RcppExports.o python.o"'的状态是2

Tab completion does not work

After typing "tf$Var", if one types tab, it becomes "tf$", instead of "tf$Variable" as expected.

My system: Ubuntu 14.04, python 3.4.3, tensorflow 0.10, installed Rtensorflow with Sys.setenv(TENSORFLOW_PYTHON_VERSION = 3).

Memory issue?

I see excessive memory use transferring numeric objects between R and Python. I'm trying to track this down in the source now.

packageDescription("tensorflow")
# Version: 0.3.0
# Date: 2016-10-11
# Built: R 3.3.1; x86_64-pc-linux-gnu; 2016-11-03 18:41:44 UTC; unix
# RemoteRepo: tensorflow
# RemoteRef: master
# RemoteSha: f85748ec526c4ff4d6e400ef8a8c92abea6d27c8

Tiny example:

library(tensorflow)
np <- import("numpy")
x <- runif(2e8)
object.size(x)
# 1600000200 bytes

x <- np$array(x)
rm(x)
gc()

Ideally this would use maybe 3.2GB RAM, or at worst I expect something like 4.8GB. But on my system this takes over 10 GB resident RAM, and consumes 4.6 GB resident RAM even after the gc() after deleting the data. The good news is that the residual RAM use does not seem to be a leak, it's maybe just a hidden cache somewhere. Still, a >2x worst-case memory overhead is a bit excessive, right? That kind of rules out sharing anything but relatively small objects.

Vague Error Output

I know there was an update to fix the issue of vague error outputs, but I'm still only getting the following whenever there is an error:

Error in py_call(attrib, args, keywords) : basic_string::resize

I'm running the newest Tensorflow on Ubuntu 14 and the newest version of the R tensorflow library.

Error: attempt to apply non-function

Hi all,
Installation procedure, as follows:
python: /usr/local/python2.7/bin/python2.7
libpython: libpython2.7.so
numpy: /usr/local/python2.7/lib/python2.7/site-packages/numpy/core/include

sessionInfo() information, as follows:
R version 3.2.2 (2015-08-14)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: CentOS release 6.3 (Final)
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] testthat_1.0.2 tensorflow_0.3.0
loaded via a namespace (and not attached):
[1] httr_1.2.1 magrittr_1.5 R6_2.2.0 tools_3.2.2
[5] withr_1.0.2 curl_2.3 crayon_1.3.2 memoise_1.0.0
[9] Rcpp_0.12.8 knitr_1.15.1 git2r_0.16.0 digest_0.6.10
[13] devtools_1.12.0

My code was:
library(tensorflow)
sess = tf$Session()

Then, i got the error message, as:
Error: attempt to apply non-function

Cloud you help me to deal with this problem?

And, i am not sure if the version of tensorflow can be updated to 0.12?

Thanks
Doudouricklin

Save and restore model

Does saving and restoring a model work with R?

I have a model

# Parameters
...

# Model
layer1 = tf$add(tf$matmul(x, weight_variable(shape(n_input, n_hidden_1))),
                bias_variable(shape(n_hidden_1)))
layer1 = tf$nn$relu(layer1)

layer2 = tf$add(tf$matmul(layer1, weight_variable(shape(n_hidden_1, n_hidden_2))),
                bias_variable(shape(n_hidden_2)))
layer2 = tf$nn$relu(layer2)

out_layer = tf$matmul(layer2, weight_variable(shape(n_hidden_2, n_classes))) +
            bias_variable(shape(n_classes))

# Initialize graph
sess <- tf$Session()
sess$run(tf$initialize_all_variables())

# Train
...

I use out_layer to make a prediction like this:

pred = sess$run(out_layer, feed_dict = dict(x = test.x))

later I save the model like this:

saver <- tf$train$Saver()
data_file <- saver$save(sess, paste0(data.dir, "my_model.ckpt"))

Then I restart R (to test if restoring works). This leads to the situation that now all tensorflow objects are <Object with null pointer>.
Now I try to restore the model like this:

sess = tf$Session()
restorer = tf$train$import_meta_graph(paste0(data.dir, "my_model.ckpt.meta"))
restorer$restore(sess, tf$train$latest_checkpoint(data.dir))

...this gives me no errors.
However, out_layer (and the other tensorflow-objects) is still an <Object with null pointer>! Does this mean, restoring the model has not really worked, or do I just have to make an effort to assign out_layer the correct pointer again?

No license

There's no LICENSE file in this repo, or any licensing indication. Please specify the license so that people know whether it's usable, e.g. in a corporate setting.

Passing NULL arguments to TensorFlow functions

Running in R

x <- tf$placeholder(tf$float32, shape = shape(NULL, 784L))
tf$contrib$layers$fully_connected(x, 10L, activation_fn = NULL)

I get

Tensor("fully_connected/Relu:0", shape=(?, 10), dtype=float32)

In Python, running the equivalent:

>>> x = tf.placeholder(tf.float32, [None, 784])
>>> tf.contrib.layers.fully_connected(x, 10, activation_fn = None)
<tf.Tensor 'fully_connected/BiasAdd:0' shape=(?, 10) dtype=float32>

I would expect to get the same kind of Tensor (fully_connected/BiasAdd:0) in R.
Maybe there's a problem on how R passes NULL arguments to Python here.

Following installation steps lead to an error in python.cpp

After having python installed (version 2.7) and tensorflow installed via pip,
I run devtools::install_github("rstudio/tensorflow") and get:

Downloading GitHub repo rstudio/tensorflow@master
from URL https://api.github.com/repos/rstudio/tensorflow/zipball/master
Installing tensorflow
'/usr/lib/R/bin/R' --no-site-file --no-environ --no-save --no-restore --quiet CMD INSTALL '/tmp/Rtmpb2mK9G/devtools29c434292a2/rstudio-tensorflow-e1b488a'
--library='/home/roir/R/x86_64-pc-linux-gnu-library/3.0' --install-tests

* installing source package ‘tensorflow’ ...
Using python binary at /usr/bin/python
Using python version 2
checking for gcc... gcc -std=gnu99
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables...
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc -std=gnu99 accepts -g... yes
checking for gcc -std=gnu99 option to accept ISO C89... none needed
configure: creating ./config.status
config.status: creating src/Makevars
config.status: creating R/config.R
** libs
g++ -I/usr/share/R/include -DNDEBUG -I/usr/include/python2.7 -I/usr/include/x86_64-linux-gnu/python2.7 -I/usr/local/lib/python2.7/dist-packages/numpy/core/include -D PYTHONLIBFILE=libpython2.7.so -I"/home/roir/R/x86_64-pc-linux-gnu-library/3.0/Rcpp/include" -fpic -O3 -pipe -g -c RcppExports.cpp -o RcppExports.o
g++ -I/usr/share/R/include -DNDEBUG -I/usr/include/python2.7 -I/usr/include/x86_64-linux-gnu/python2.7 -I/usr/local/lib/python2.7/dist-packages/numpy/core/include -D PYTHONLIBFILE=libpython2.7.so -I"/home/roir/R/x86_64-pc-linux-gnu-library/3.0/Rcpp/include" -fpic -O3 -pipe -g -c python.cpp -o python.o
python.cpp: In function ‘PyObjectXPtr py_dict(const List&, const List&)’:
python.cpp:959:13: error: ‘i’ does not name a type
for (auto i = 0; i<keys.length(); i++) {
^
python.cpp:959:20: error: expected ‘;’ before ‘i’
for (auto i = 0; i<keys.length(); i++) {
^
python.cpp:959:20: error: ‘i’ was not declared in this scope
make: *** [python.o] Error 1
ERROR: compilation failed for package ‘tensorflow’

  • removing ‘/home/roir/R/x86_64-pc-linux-gnu-library/3.0/tensorflow’
    Error: Command failed (1)

Unable to install with Tensorflow installed to Windows 7

I have installed Rtools, and the python 3.5 package recommended by Google for tensorflow. I have confirmed that Tensorflow works from the cmd prompt when invoked. I believe the config file for windows needs added to this package.

Another installation issue

The problem is very similar to Issues #24 and #28 (but with a different error message). I've spent the last 4 hrs trying to debug with no luck.

Sys.setenv(TENSORFLOW_PYTHON="/usr/local/bin/python")
devtools::install_github("rstudio/tensorflow", force = TRUE)
library(tensorflow)
Reloading installed tensorflow
The tensorflow package requires version 0.12 or later of TensorFlow
If you have not yet installed TensorFlow, see https://www.tensorflow.org/get_started/
Configuration:
python: /usr/local/bin/python
libpython: /usr/local/opt/python/Frameworks/Python.framework/Versions/2.7/lib/python2.7/config/libpython2.7.dylib
numpy: /usr/local/lib/python2.7/site-packages/numpy/core/include

I have checked TensorFlow installation is ok:

import tensorflow as tf
tf.version
'0.12.1'

Axel.

Example doesn't run

First, I prefixed py_import() with tensorflow::: but then it barked on this:

> library(tensorflow)
> source('~/git/tensorflow/inst/examples/mnist_softmax.R')
Extracting /tmp/data/train-images-idx3-ubyte.gz
Extracting /tmp/data/train-labels-idx1-ubyte.gz
Extracting /tmp/data/t10k-images-idx3-ubyte.gz
Extracting /tmp/data/t10k-labels-idx1-ubyte.gz
 Error in eval(expr, envir, enclos) : 
  Cannot interpret feed_dict key as Tensor: The name 'x' looks like an \
  (invalid) Operation name, not a Tensor. Tensor names must be of the \
  form "<op_name>:<output_index>". 
> 

tensor shape to R object?

How can I convert a tensor shape object to an R object?
Minimal example:

x <- tf$zeros(shape(10L))
x$get_shape()
# (10,)

I would expect getting something like:

[1] 10 NA

autocompletion of deprecated attributes throws error in RStudio

Reproduce with the following code:

library(tensorflow)
lr <- tf$contrib$learn$LinearRegressor(list(tf$contrib$layers$real_valued_column("")))
lr$<TAB>

You should see an error message with something like:

WARNING:tensorflow:From <unknown>: bias_ (from tensorflow.contrib.learn.python.learn.estimators.linear) is deprecated and will be removed after 2016-10-30.
Instructions for updating:
This method will be removed after the deprecation date. To inspect variables, use get_variable_names() and get_variable_value().
WARNING:tensorflow:From <unknown>: weights_ (from tensorflow.contrib.learn.python.learn.estimators.linear) is deprecated and will be removed after 2016-10-30.
Instructions for updating:
This method will be removed after the deprecation date. To inspect variables, use get_variable_names() and get_variable_value().
Error in py_module_impl(module) : 
  ValueError: Couldn't find 'checkpoint' file or checkpoints in given directory /var/folders/tm/5dt8p5s50x58br1k6wpqnwx00000gn/T/tmp50j1nW

A simpler (non-RStudio) repro would be:

library(tensorflow)
lr <- tf$contrib$learn$LinearRegressor(list(tf$contrib$layers$real_valued_column("")))
tensorflow:::py_get_attr(lr, "bias_")

I wonder if we should just manually filter these out of the autocompletion list, or if there's a safer way to access these attributes without triggering these warnings?

Continuous Integration

Seems like more and more tutorials are coming soon, including some functionalities from contrib module. For example, some people are testing TF.Learn out by following its tutorials. See #14

It would be good to setup continuous integration for the repo so some tutorials will be tested against master branch of TF since contrib interface will be changing quite often until it's merged into core.

error in reloading R package (Symbol not found: _PyBool_Type)

Hi I've run tensorflow with Python 3.5 on my Mac OS X Yosemite 10.10.5 and am looking forward to using tensorflow from RStudio. I've run into a problem using both RStudio and R in terminal. The installation finds Python and passes the other tests (C compiler works, etc.) but then cannot find _PyBool_Type in tensorflow.so at the last moment.

I run:

Sys.setenv(TENSORFLOW_PYTHON_VERSION = 3)
devtools::install_github("rstudio/tensorflow")

And then here's the first error the installation throws:

** testing if installed package can be loaded
Error in dyn.load(file, DLLpath = DLLpath, ...) : 
  unable to load shared object '/Library/Frameworks/R.framework/Versions/3.3/Resources/library/tensorflow/libs/tensorflow.so':
  dlopen(/Library/Frameworks/R.framework/Versions/3.3/Resources/library/tensorflow/libs/tensorflow.so, 6): Symbol not found: _PyBool_Type
  Referenced from: /Library/Frameworks/R.framework/Versions/3.3/Resources/library/tensorflow/libs/tensorflow.so
  Expected in: flat namespace
 in /Library/Frameworks/R.framework/Versions/3.3/Resources/library/tensorflow/libs/tensorflow.so
Error: loading failed

The version of Python I'd like to use is in "/Library/Frameworks/Python.framework/Versions/3.5/bin" (though 2.6, 2.7 are installed elsewhere). The output from the installation suggests that install is looking in the right place though:

** libs
clang++ -std=c++11 -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG -I/Library/Frameworks/Python.framework/Versions/3.5/include/python3.5m -I/Library/Frameworks/Python.framework/Versions/3.5/include/python3.5m -I/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/numpy/core/include -D PYTHONLIBFILE=libpython3.5.so -I/usr/local/include -I/usr/local/include/freetype2 -I/opt/X11/include -I"

Any ideas?

Here is the full output of the session:

Restarting R session...

> Sys.setenv(TENSORFLOW_PYTHON_VERSION = 3)
> devtools::install_github("rstudio/tensorflow")
Downloading GitHub repo rstudio/tensorflow@master
from URL https://api.github.com/repos/rstudio/tensorflow/zipball/master
Installing tensorflow
'/Library/Frameworks/R.framework/Resources/bin/R' --no-site-file --no-environ  \
  --no-save --no-restore --quiet CMD INSTALL  \
  '/private/var/folders/d8/bsgtpg7s6ndg30v95srzkdh40000gn/T/RtmpcToIH6/devtools262e2a185b0a/rstudio-tensorflow-8db4818'  \
  --library='/Library/Frameworks/R.framework/Versions/3.3/Resources/library'  \
  --install-tests 

* installing *source* package ‘tensorflow’ ...
Using python binary from PATH
Using python version 3
checking for gcc... clang
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables... 
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether clang accepts -g... yes
checking for clang option to accept ISO C89... none needed
configure: creating ./config.status
config.status: creating src/Makevars
config.status: creating R/config.R
** libs
clang++ -std=c++11 -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG -I/Library/Frameworks/Python.framework/Versions/3.5/include/python3.5m -I/Library/Frameworks/Python.framework/Versions/3.5/include/python3.5m -I/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/numpy/core/include -D PYTHONLIBFILE=libpython3.5.so -I/usr/local/include -I/usr/local/include/freetype2 -I/opt/X11/include -I"/Library/Frameworks/R.framework/Versions/3.3/Resources/library/Rcpp/include"   -fPIC  -Wall -mtune=core2 -g -O2 -c RcppExports.cpp -o RcppExports.o
clang++ -std=c++11 -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG -I/Library/Frameworks/Python.framework/Versions/3.5/include/python3.5m -I/Library/Frameworks/Python.framework/Versions/3.5/include/python3.5m -I/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/numpy/core/include -D PYTHONLIBFILE=libpython3.5.so -I/usr/local/include -I/usr/local/include/freetype2 -I/opt/X11/include -I"/Library/Frameworks/R.framework/Versions/3.3/Resources/library/Rcpp/include"   -fPIC  -Wall -mtune=core2 -g -O2 -c python.cpp -o python.o
clang++ -std=c++11 -dynamiclib -Wl,-headerpad_max_install_names -undefined dynamic_lookup -single_module -multiply_defined suppress -L/Library/Frameworks/R.framework/Resources/lib -L/usr/local/lib -o tensorflow.so RcppExports.o python.o -L/Library/Frameworks/R.framework/Resources/lib -lRlapack -L/Library/Frameworks/R.framework/Resources/lib -lRblas -L/usr/local/lib/gcc/x86_64-apple-darwin13.0.0/4.8.2 -lgfortran -lquadmath -lm -F/Library/Frameworks/R.framework/.. -framework R -Wl,-framework -Wl,CoreFoundation
installing to /Library/Frameworks/R.framework/Versions/3.3/Resources/library/tensorflow/libs
** R
** inst
** tests
** preparing package for lazy loading
** help
*** installing help indices
** building package indices
** testing if installed package can be loaded
Error in dyn.load(file, DLLpath = DLLpath, ...) : 
  unable to load shared object '/Library/Frameworks/R.framework/Versions/3.3/Resources/library/tensorflow/libs/tensorflow.so':
  dlopen(/Library/Frameworks/R.framework/Versions/3.3/Resources/library/tensorflow/libs/tensorflow.so, 6): Symbol not found: _PyBool_Type
  Referenced from: /Library/Frameworks/R.framework/Versions/3.3/Resources/library/tensorflow/libs/tensorflow.so
  Expected in: flat namespace
 in /Library/Frameworks/R.framework/Versions/3.3/Resources/library/tensorflow/libs/tensorflow.so
Error: loading failed
Execution halted
ERROR: loading failed
* removing ‘/Library/Frameworks/R.framework/Versions/3.3/Resources/library/tensorflow’
Error: Command failed (1)

Reloading installed tensorflow ImportError: libcudart.so.7.5: cannot open shared object file: No such file or directory

When I installed the tensorflow package using the R shell, it's fine.

But when installing via the rstudio web GUI, I get the following error:
.......

  • DONE (tensorflow)
    Reloading installed tensorflow
    ImportError: libcudart.so.7.5: cannot open shared object file: No such file or directory
    If you have not yet installed TensorFlow, see https://www.tensorflow.org/get_started/

......

Is the Anaconda issue still relevant?

I noticed the configure.ac reject any Anaconda python. The issue linked is from 2015 and I wanted to make sure this was still relevant and that building a new python from scratch was the only solution.

We run on Linux (RHEL 7.2 in this case).

We have been using Anaconda python on all our nodes for years and would like to keep this standard. It greatly facilitates managing a larger scale python deployment.

tab completion?

works in the command line (Linux), not from RStudio though. That is, tab completion of python objects like np below:

library(tensorflow)
np <- import("numpy")

RStudio (Server) Version 0.99.903

platform x86_64-pc-linux-gnu
svn rev 69053
version.string R version 3.2.2 (2015-08-14)

Any ideas?

loading error in Mac OS

Hi,
I used pip to install tensorflow and the R package was also installed as following:
devtools::install_github("rstudio/tensorflow")

When I ran the following lines of code:
library(tensorflow); sess = tf$Session()
An error message was occurred:
错误: 不适用于非函数

What's the problem?
Best regards!
Bo

Could not locate error

I have python3 installed at /usr/local/bin/python3. I also installed Tensorflow using pip3.
When I enter Sys.setenv(TENSORFLOW_PYTHON="/usr/local/bin/python3") and then
devtools::install_github("rstudio/tensorflow"), I get the error

* installing *source* package ‘tensorflow’ ...
Using python binary at /usr/local/bin/python3
Could not locate 
ERROR: configuration failed for package ‘tensorflow’
* removing ‘/Library/Frameworks/R.framework/Versions/3.3/Resources/library/tensorflow’
Error: Command failed (1)

What did I do wrong?

System: macOS

installation failure on OS X with homebrew python

(Sorry if I'm reporting this prematurely / this isn't expected to work yet!)

When attempting to build on OS X, I see a build during execution of .onLoad(), etc.

** testing if installed package can be loaded
Error : .onLoad failed in loadNamespace() for 'tensorflow', details:
  call: eval(substitute(expr), envir, enclos)
  error: dlopen(libpython2.7.dylib, 10): image not found
Error: loading failed

Any thoughts? My best guess -- does the pythonSharedLibrary() function need to produce the absolute path to a Python library, or do I need to ensure my DYLD_FALLBACK_LIBRARY_PATH has the directory pointing at libpython2.7.dylib, or otherwise?

==> R CMD INSTALL --no-multiarch --with-keep.source tensorflow

* installing to library ‘/Users/kevin/Library/R/3.3/library’
* installing *source* package ‘tensorflow’ ...
Using system version of python
checking for gcc... clang-3.8
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables... 
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether clang-3.8 accepts -g... yes
checking for clang-3.8 option to accept ISO C89... none needed
configure: creating ./config.status
config.status: creating src/Makevars
make: Nothing to be done for `all'.
** libs
installing to /Users/kevin/Library/R/3.3/library/tensorflow/libs
** R
** inst
** preparing package for lazy loading
** help
*** installing help indices
** building package indices
** testing if installed package can be loaded
Error : .onLoad failed in loadNamespace() for 'tensorflow', details:
  call: eval(substitute(expr), envir, enclos)
  error: dlopen(libpython2.7.dylib, 10): image not found
Error: loading failed
Execution halted
ERROR: loading failed
* removing ‘/Users/kevin/Library/R/3.3/library/tensorflow’

The generated Makevars seems to point to a homebrew installation of Python:

# Compile as C++11 to get (inter alia) 'long long'
CXX_STD=CXX11

# Required vars
PKG_LIBS=-L/usr/local/Cellar/python/2.7.12/Frameworks/Python.framework/Versions/2.7/lib/python2.7/config -lpython2.7 -ldl -framework CoreFoundation
PKG_CPPFLAGS=-I/usr/local/Cellar/python/2.7.12/Frameworks/Python.framework/Versions/2.7/include/python2.7 -I/usr/local/Cellar/python/2.7.12/Frameworks/Python.framework/Versions/2.7/include/python2.7 -I/usr/local/lib/python2.7/site-packages/numpy/core/include -D PYTHONLIBFILE=libpython2.7.so

CI skipping tests

I just noticed that the Travis build is skipping tests, because the R package is failing to link to the TensorFlow installation.

Skipped ------------------------------------------------------------------------
1. hello.R example runs successfully (@test-examples.R#29) - TensorFlow not available for test

...

11. passing non-vector indices errors (@test-extract-syntax.R#177) - TensorFlow not available for test
DONE ===========================================================================

Scrolling back through the build history, here's the first instance of this occurring, 27 days ago: https://travis-ci.org/rstudio/tensorflow/jobs/164908030#L1074, though I can't fathom how that commit could have caused the problem.

The Travis set up (either then or now) doesn't report the message on attempting to load the package, so I'm not sure what's causing this.

indexing tensors

Thanks you so much for this package!

This is a feature request: would it be possible to provide a slimmer syntax for subsetting tensors to match python/tf tensor subsetting, preferably using R's [?

i.e., I can do this in Python:

import tensorflow as tf
x = tf.zeros(3)
y = x[1]
sess = tf.Session()
sess.run(y)
0.0

but in R, no dice:

library (tensorflow)
x = tf$zeros(3)
y = x[1]
Error in x[1] : object of type 'externalptr' is not subsettable

I can use other tf functions like slice and gather, but it's fairly clunky:

y = tf$gather(x, 1L)
sess = tf$Session()
sess$run(y)
[1] 0

Examples of tf$learn not working

I'm trying to run the example in this file and it's returning a lot of warnings and errors see log below.

My session info:

> sessionInfo()
R version 3.2.3 (2015-12-10)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 16.04 LTS

locale:
 [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C               LC_TIME=en_US.UTF-8       
 [4] LC_COLLATE=en_US.UTF-8     LC_MONETARY=en_US.UTF-8    LC_MESSAGES=en_US.UTF-8   
 [7] LC_PAPER=en_US.UTF-8       LC_NAME=C                  LC_ADDRESS=C              
[10] LC_TELEPHONE=C             LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C       

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] dplyr_0.5.0      purrr_0.2.2      readr_0.2.2      tidyr_0.6.0      tibble_1.1       ggplot2_2.1.0   
[7] tidyverse_1.0.0  tensorflow_0.3.0 Matrix_1.2-3    

loaded via a namespace (and not attached):
 [1] Rcpp_0.12.8      lattice_0.20-33  assertthat_0.1   R6_2.1.2         grid_3.2.3       plyr_1.8.3      
 [7] DBI_0.4-1        gtable_0.2.0     magrittr_1.5     scales_0.4.0     tools_3.2.3      munsell_0.4.3   
[13] colorspace_1.2-6
> tf$VERSION
[1] "0.12.1"

Log:

> library(tensorflow)
> 
> # Here we just use all data as both training and testing (cheating) but
> # in practice you should do your own sampling, such as stratified sampling
> train_inds <- 1:150
> test_inds <- 1:150
> 
> temp_model_dir <- tempfile()
> dir.create(temp_model_dir)
> 
> datasets <- tf$contrib$learn$datasets$load_dataset("iris")
> 
> # Infer the real-valued feature columns
> feature_columns <- tf$contrib$learn$infer_real_valued_columns_from_input(datasets$data)
WARNING:tensorflow:float64 is not supported by many models, consider casting to float32.
> 
> # Initialize a DNN classifier with hidden units 10, 15, 10 in each layer
> classifier <- tf$contrib$learn$DNNClassifier(
+   feature_columns = feature_columns,
+   hidden_units = c(10L, 15L, 10L),
+   n_classes = 3L,
+   model_dir = temp_model_dir)
> 
> # Train a DNN Classifier
> classifier$fit(datasets$data[train_inds, ], datasets$target[train_inds], steps = 100)
WARNING:tensorflow:From /home/servicedesk/.local/lib/python3.5/site-packages/tensorflow/contrib/learn/python/learn/estimators/dnn.py:315 in fit.: calling BaseEstimator.fit (from tensorflow.contrib.learn.python.learn.estimators.estimator) with x is deprecated and will be removed after 2016-12-01.
Instructions for updating:
Estimator is decoupled from Scikit Learn interface by moving into
separate class SKCompat. Arguments x, y and batch_size are only
available in the SKCompat class, Estimator will only accept input_fn.
Example conversion:
  est = Estimator(...) -> est = SKCompat(Estimator(...))
WARNING:tensorflow:From /home/servicedesk/.local/lib/python3.5/site-packages/tensorflow/contrib/learn/python/learn/estimators/dnn.py:315 in fit.: calling BaseEstimator.fit (from tensorflow.contrib.learn.python.learn.estimators.estimator) with y is deprecated and will be removed after 2016-12-01.
Instructions for updating:
Estimator is decoupled from Scikit Learn interface by moving into
separate class SKCompat. Arguments x, y and batch_size are only
available in the SKCompat class, Estimator will only accept input_fn.
Example conversion:
  est = Estimator(...) -> est = SKCompat(Estimator(...))
WARNING:tensorflow:From /home/servicedesk/.local/lib/python3.5/site-packages/tensorflow/contrib/learn/python/learn/estimators/dnn.py:315 in fit.: calling BaseEstimator.fit (from tensorflow.contrib.learn.python.learn.estimators.estimator) with batch_size is deprecated and will be removed after 2016-12-01.
Instructions for updating:
Estimator is decoupled from Scikit Learn interface by moving into
separate class SKCompat. Arguments x, y and batch_size are only
available in the SKCompat class, Estimator will only accept input_fn.
Example conversion:
  est = Estimator(...) -> est = SKCompat(Estimator(...))
WARNING:tensorflow:float64 is not supported by many models, consider casting to float32.
WARNING:tensorflow:*******************************************************
WARNING:tensorflow:TensorFlow's V1 checkpoint format has been deprecated.
WARNING:tensorflow:Consider switching to the more efficient V2 format:
WARNING:tensorflow:   `tf.train.Saver(write_version=tf.train.SaverDef.V2)`
WARNING:tensorflow:now on by default.
WARNING:tensorflow:*******************************************************
WARNING:tensorflow:*******************************************************
WARNING:tensorflow:TensorFlow's V1 checkpoint format has been deprecated.
WARNING:tensorflow:Consider switching to the more efficient V2 format:
WARNING:tensorflow:   `tf.train.Saver(write_version=tf.train.SaverDef.V2)`
WARNING:tensorflow:now on by default.
WARNING:tensorflow:*******************************************************
DNNClassifier
> 
> # Generate predictiosn on new data
> predictions <- classifier$predict(datasets$data[test_inds, ])
WARNING:tensorflow:From /home/servicedesk/.local/lib/python3.5/site-packages/tensorflow/contrib/learn/python/learn/estimators/dnn.py:348 in predict.: calling BaseEstimator.predict (from tensorflow.contrib.learn.python.learn.estimators.estimator) with x is deprecated and will be removed after 2016-12-01.
Instructions for updating:
Estimator is decoupled from Scikit Learn interface by moving into
separate class SKCompat. Arguments x, y and batch_size are only
available in the SKCompat class, Estimator will only accept input_fn.
Example conversion:
  est = Estimator(...) -> est = SKCompat(Estimator(...))
WARNING:tensorflow:From /home/servicedesk/.local/lib/python3.5/site-packages/tensorflow/contrib/learn/python/learn/estimators/dnn.py:348 in predict.: calling BaseEstimator.predict (from tensorflow.contrib.learn.python.learn.estimators.estimator) with batch_size is deprecated and will be removed after 2016-12-01.
Instructions for updating:
Estimator is decoupled from Scikit Learn interface by moving into
separate class SKCompat. Arguments x, y and batch_size are only
available in the SKCompat class, Estimator will only accept input_fn.
Example conversion:
  est = Estimator(...) -> est = SKCompat(Estimator(...))
WARNING:tensorflow:From /home/servicedesk/.local/lib/python3.5/site-packages/tensorflow/contrib/learn/python/learn/estimators/dnn.py:348 in predict.: calling BaseEstimator.predict (from tensorflow.contrib.learn.python.learn.estimators.estimator) with as_iterable is deprecated and will be removed after 2016-12-01.
Instructions for updating:
Estimator is decoupled from Scikit Learn interface by moving into
separate class SKCompat. Arguments x, y and batch_size are only
available in the SKCompat class, Estimator will only accept input_fn.
Example conversion:
  est = Estimator(...) -> est = SKCompat(Estimator(...))
WARNING:tensorflow:float64 is not supported by many models, consider casting to float32.
> accuracy <- sum(predictions == datasets$target[test_inds]) / length(predictions)
Error in predictions == datasets$target[test_inds] : 
  comparison (1) is possible only for atomic and list types
> print(paste0("The accuracy is ", accuracy))
Error in print(paste0("The accuracy is ", accuracy)) : 
  error in evaluating the argument 'x' in selecting a method for function 'print': Error in paste0("The accuracy is ", accuracy) : 
  object 'accuracy' not found

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.