rstudio / tfdatasets

R interface to TensorFlow Datasets API
https://tensorflow.rstudio.com/tools/tfdatasets/
34 stars 12 forks source link

from_generator method #2

Open dfalbel opened 6 years ago

dfalbel commented 6 years ago

I wonder if it's possible to implement the from_generator method. I was trying to implement similar to what's in keras, but got a C stack usage error. Here's the minimal example:

library(tensorflow)
library(tfdatasets)

gen <- function() {
  i <- 0
  function() {
    i <<- i + 1
    i
  }
}

gen2 <- function() reticulate::py_iterator(gen())

dataset <- tf$data$Dataset$from_generator(generator = gen2, output_types =  tuple(tf$float64))
iterator <- dataset$make_one_shot_iterator()
the_next <- iterator$get_next()

sess <- tf$Session()
the_next[[1]]$eval(session = sess) 
jjallaire commented 6 years ago

Hmmm...not sure why this would be, perhaps something to do with threading. I'll polk at it and see if any solutions appear.

zyaar commented 6 years ago

Was there any update on this?