Combines consecutive elements of this dataset into padded batches

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.

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