0

I loaded package tensorflow and run library(tensorflow). I got the message that tf is masked by .GlobalEnv. Not sure what that means, but it seemed not to be an error.

I then ran install_tensorflow() and that seems to run fine. I now ran library(tensorflow) again without a message.

When checking the tensorflow installation with tf_config() I get the tensorflow information (version v.1.4.0) and Python v3.6.

It all seemed OK. But when I am running hello <- tf$constant('Hello, TensorFlow!') or any other tf$XXX, I get the error:

Error in tf$constant : $ operator is invalid for atomic vectors.

So somehow tensorflow is not correctly installed. ?tf opens the right description for the tensorflow module.

Anyone has an idea?

TylerH
  • 20,799
  • 66
  • 75
  • 101
Christian
  • 11
  • 1

2 Answers2

1

Thanks that was it. I restarted R and deleted all gloval environment content. Then I could intall tensorflow without the message. I still countered a conda environment issue, which I found a solution in another post. Here is the code which worked. Note, in the beginning all the global environment was empty:

library(tensorflow)
install_tensorflow()
library(reticulate)
library(tensorflow)
use_condaenv("r-tensorflow")
sess = tf$Session()
jogo
  • 12,469
  • 11
  • 37
  • 42
Christian
  • 11
  • 1
0

First error you are getting is because you have things (objects) in your global environment defined with the same name as other things in your package. As stated in your error, the $ operation can only be done for recursive objects and not atomic.I would probably guess you have an atomic tf somewhere around.

You might find some more info here

Meaning of objects being masked by the global environment

Neoromanzer
  • 434
  • 2
  • 15