library(tfdatasets)
<- text_line_dataset("mtcars.csv", record_spec = mtcars_spec) %>%
dataset dataset_prepare(x = c(mpg, disp), y = cyl) %>%
dataset_batch(128) %>%
dataset_repeat(10)
<- make_iterator_one_shot(dataset)
iter <- iterator_get_next(iter)
next_batch
with_dataset({
while(TRUE) {
<- sess$run(next_batch)
batch # use batch$x and batch$y tensors
} })
with_dataset
Execute code that traverses a dataset
Description
Execute code that traverses a dataset
Usage
with_dataset(expr)
Arguments
Arguments | Description |
---|---|
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).