description: Add padding to the beginning and end of data in a specific dimension.
Add padding to the beginning and end of data in a specific dimension.
text.pad_along_dimension(
data, axis=-1, left_pad=None, right_pad=None, name=None
)
Returns a tensor constructed from data, where each row in dimension axis
is replaced by the concatenation of the left padding followed by the row
followed by the right padding. I.e., if L=left_pad.shape[0] and
R=right_pad.shape[0], then:
result[i1...iaxis, 0:L] = left_pad
result[i1...iaxis, L:-R] = data[i0...iaxis]
result[i1...iaxis, -R:] = right_pad| `[O1...ON, L + A + R, I1...IM]` A potentially ragged `K` dimensional tensor with outer dimensions of size `O1...ON`; padded axis dimension size `L+A+R`; and inner dimensions of size `I1...IM`. If `data` is a `RaggedTensor`, then the returned tensor is a `RaggedTensor` with the same `ragged_rank`. |