length.tf_dataset: Get Dataset length

Description Usage Arguments Value Examples

View source: R/dataset_methods.R

Description

Returns the length of the dataset.

Usage

1
2
3
4
5
## S3 method for class 'tf_dataset'
length(x)

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

Arguments

x

a tf.data.Dataset object.

Value

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

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
## Not run: 
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

## End(Not run)

tfdatasets documentation built on Nov. 10, 2021, 1:07 a.m.