tensorflow/models · error · ValueError
Illegal padding value; must be one of "left", "right" or Non
Error message
Illegal padding value; must be one of "left", "right" or None.
What it means
Error "Illegal padding value; must be one of "left", "right" or None." thrown in tensorflow/models.
Source
Thrown at official/nlp/modeling/layers/kernel_attention.py:73
be divisible by the chunk_length.
Returns:
Padded tensor with shape[axis] divisible by chunk_length.
"""
if padding is None:
return tensor
shape = tf.shape(tensor)
rank = tf.rank(tensor)
if axis < 0:
axis += rank
axis_length = shape[axis]
pad_length = -axis_length % chunk_length
if padding == "right":
axis_paddings = [[0, pad_length]]
elif padding == "left":
axis_paddings = [[pad_length, 0]]
else:
raise ValueError(
"Illegal padding value; must be one of \"left\", \"right\" or None.")
paddings = tf.concat([
tf.zeros([axis, 2], dtype=tf.int32), axis_paddings,
tf.zeros([rank - axis - 1, 2], dtype=tf.int32)
],
axis=0)
return tf.pad(tensor, paddings)
def split_tensor_into_chunks(tensor, axis, chunk_length):
"""Reshape tensor along given axis using chunk_length.
Args:
tensor: Input tensor.
axis: Reshape tensor along this axis.
chunk_length: Split the axis into [axis/chunk_length, chunk_length]
Returns:View on GitHub (pinned to e006f5f0d5)
When it happens
Trigger: Thrown at official/nlp/modeling/layers/kernel_attention.py:73 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of tensorflow/models@e006f5f0d5 (2026-08-24).
Data as JSON: /api/errors/b2127ca5da2d2037.
Report an issue: GitHub.