tfdatasets (version 1.9)

dataset_padded_batch: Combines consecutive elements of this dataset into padded batches

Description

This method combines multiple consecutive elements of this dataset, which might have different shapes, into a single element. The tensors in the resulting element have an additional outer dimension, and are padded to the respective shape in padded_shapes.

Usage

dataset_padded_batch(dataset, batch_size, padded_shapes,
  padding_values = NULL, drop_remainder = FALSE)

Arguments

dataset

A dataset

batch_size

An integer, representing the number of consecutive elements of this dataset to combine in a single batch.

padded_shapes

A nested structure of tf$TensorShape or integer vector tensor-like objects representing the shape to which the respective component of each input element should be padded prior to batching. Any unknown dimensions (e.g. tf$Dimension(NULL) in a tf$TensorShape or -1 in a tensor-like object) will be padded to the maximum size of that dimension in each batch.

padding_values

(Optional) A nested structure of scalar-shaped tf$Tensor, representing the padding values to use for the respective components. Defaults are 0 for numeric types and the empty string for string types.

drop_remainder

Ensure that batches have a fixed size by omitting any final smaller batch if it's present. Note that this is required for use with the Keras tensor inputs to fit/evaluate/etc.

Value

A dataset

See Also

Other dataset methods: dataset_batch, dataset_cache, dataset_concatenate, dataset_decode_delim, dataset_filter, dataset_interleave, dataset_map_and_batch, dataset_map, dataset_prefetch_to_device, dataset_prefetch, dataset_repeat, dataset_shuffle_and_repeat, dataset_shuffle, dataset_skip, dataset_take