error when setting up a tensorflow session

Split from Deep Learning with Keras and TensorFlow in R Workflow - rstudio::conf 2020


Hi I am getting an error trying to set up as session in tensor flow my code:

library(tensorflow)
install_tensorflow()

Create your session

sess <- tf$Session()

Installation complete.

Restarting R session...

Create your session

sess <- tf$Session()
Error in py_get_attr_impl(x, name, silent) :
AttributeError: module 'tensorflow' has no attribute 'Session'

Any idea?

@rochefrancisco This is likely due to the recent Tensorflor 2.0 release. See this Stackoverflow question (link).

Instead of using tf$Session() try tf$compat$v1$Session()

Thanks, I did Stackoverflow in my MAc in the terminal and I still got the error. Although, I ran some code of RStudio Keras and it ran a few lines of RStudio and it did run perfectly (code:
library(tensorflow)
#install.packages("tfautograph")
library(tfautograph)
library(keras)
#install.packages("tfdatasets")
library(tfdatasets)

tf$executing_eagerly()
x <- matrix(2, ncol = 1, nrow = 1)
m <- tf$matmul(x, x)
m
a <- tf$constant(matrix(c(1,2,3,4), ncol = 2))
a)

I will continue trying

Thanks for the help!
Francisoc

I'm sorry but I can't reproduce your error.

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.