length.tf_dataset: Get Dataset length

View source: R/dataset_methods.R

length.tf_datasetR Documentation

Get Dataset length

Description

Returns the length of the dataset.

Usage

## 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

## 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 Sept. 11, 2024, 8:53 p.m.