tensorflow/models · error · ValueError
All features from the feature_names set must be tensors with
Error message
All features from the feature_names set must be tensors with the same shape except for the last dimension, but got features with incompatible shapes {feature_shapes} What it means
Error "All features from the feature_names set must be tensors with the same shape except for the last dimension, but got features with incompatible shapes {feature_shapes}" thrown in tensorflow/models.
Source
Thrown at official/recommendation/uplift/layers/encoders/concat_features.py:82
if feature_name in self._feature_names
}
most_specific_shape = tf.TensorShape(None)
for feature_name, shape in feature_shapes.items():
if not isinstance(shape, tf.TensorShape):
raise TypeError(
f"Got unsupported tensor shape type for feature {feature_name}. The"
" feature tensor must be one of `tf.Tensor`, `tf.SparseTensor` or"
" `tf.RaggedTensor`, with a well defined tensor shape but got shape"
f" {shape} instead."
)
shape = shape[:-1]
if shape.is_subtype_of(most_specific_shape):
most_specific_shape = shape
elif not most_specific_shape.is_subtype_of(shape):
raise ValueError(
"All features from the feature_names set must be tensors with the"
" same shape except for the last dimension, but got features with"
f" incompatible shapes {feature_shapes}"
)
super().build(input_shapes)
def call(self, inputs: types.DictOfTensors) -> tf.Tensor:
features = []
for feature_name, feature in inputs.items():
if feature_name in self._feature_names:
if isinstance(feature, tf.Tensor):
features.append(feature)
elif isinstance(feature, tf.SparseTensor):
features.append(tf.sparse.to_dense(feature))
elif isinstance(feature, tf.RaggedTensor):
features.append(feature.to_tensor())View on GitHub (pinned to e006f5f0d5)
When it happens
Trigger: Thrown at official/recommendation/uplift/layers/encoders/concat_features.py:82 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/8f66c9966efd6365.
Report an issue: GitHub.