tf_quant_finance.math.pad.pad_date_tensors

Last updated: 2023-03-16.

tf_quant_finance.math.pad.pad_date_tensors#

View source

Pads the innermost dimension of DateTensors to a common shape.

tf_quant_finance.math.pad.pad_date_tensors(
    date_tensors, name=None
)

Given a list of DateTensors of shapes batch_shape_i + [n_i], pads the innermost dimension of each corresponding ordinal tensor to batch_shape_i + [max(n_i)]. For each ordinal tensor t, the padding is done with values t[..., -1].

Example#

x = [(2020, 1, 1), (2021, 2, 2)]
y = [(2019, 5, 5), (2028, 10, 21), (2028, 11, 10)]
pad_date_tensors([x, y])
# Expected: [DateTensor: [(2020, 1, 1), (2021, 2, 2), (2021, 2, 2)],
#            DateTensor: [(2019, 5, 5), (2028, 10, 21), (2028, 11, 10)]]

Args:#

  • date_tensors: a list of tensors of shapes batch_shape_i + [n_i].

  • name: Python string. The name to give to the ops created by this class. Default value: None which maps to the default name pad_date_tensors.

Returns:#

A list of DateTensors of shape batch_shape_i + [max(n_i)].