Learn R Programming

tfdatasets (version 2.17.0)

length.tf_dataset: Get Dataset length

Description

Returns the length of the dataset.

Usage

# S3 method for tf_dataset
length(x)

# S3 method for tensorflow.python.data.ops.dataset_ops.DatasetV2 length(x)

Value

Either Inf if the dataset is infinite, NA if the dataset length is unknown, or an R numeric if it is known.

Arguments

x

a tf.data.Dataset object.

Examples

Run this code
if (FALSE) {
range_dataset(0, 42) %>% length()
# 42

range_dataset(0, 42) %>% dataset_repeat() %>% length()
# Inf

range_dataset(0, 42) %>% dataset_repeat() %>%
  dataset_filter(function(x) TRUE) %>% length()
# NA
}

Run the code above in your browser using DataLab