tf_quant_finance.datetime.dates_from_tensor

Last updated: 2023-03-16.

tf_quant_finance.datetime.dates_from_tensor#

View source

Creates DateTensor from a single tensor containing years, months and days.

tf_quant_finance.datetime.dates_from_tensor(
    tensor, validate=True
)

This function is complementary to DateTensor.to_tensor: given an int32 Tensor of shape (…, 3), creates a DateTensor. The three elements of the last dimension are years, months and days, in this order.

Args:#

  • tensor: Tensor of type int32 and shape (…, 3).

  • validate: Whether to validate the dates.

Returns:#

DateTensor object.

Example#

tensor = tf.constant([[2015, 4, 15], [2017, 12, 30]], dtype=tf.int32)
date_tensor = tff.datetime.dates_from_tensor(tensor)