Execute code that traverses a dataset
Execute code that traverses a dataset
with_dataset(expr)
Arguments
expr | Expression to execute |
Details
When a dataset iterator reaches the end, an out of range runtime error
will occur. You can catch and ignore the error when it occurs by wrapping
your iteration code in a call to with_dataset()
(see the example
below for an illustration).
Examples
# NOT RUN {
library(tfdatasets)
dataset <- text_line_dataset("mtcars.csv", record_spec = mtcars_spec) %>%
dataset_prepare(x = c(mpg, disp), y = cyl) %>%
dataset_batch(128) %>%
dataset_repeat(10)
batch <- next_batch(dataset)
with_dataset({
while(TRUE) {
# use batch$x and batch$y tensors
}
})
# }