tensorflow/models · error · ValueError

feature_names must be a non-empty list of strings but got {f

Error message

feature_names must be a non-empty list of strings but got {feature_names} instead.

What it means

Error "feature_names must be a non-empty list of strings but got {feature_names} instead." thrown in tensorflow/models.

Source

Thrown at official/recommendation/uplift/layers/encoders/concat_features.py:46

  Takes a dictionary of feature tensors as input and concatenates the specified
  features into a single tensor. The tensors are concatenated along their last
  axis. Sparse and ragged tensors are converted to dense tensors before being
  concatenated.
  """

  def __init__(self, feature_names: Sequence[str], **kwargs):
    """Initializes a feature concatenation encoder.

    Args:
      feature_names: names of the input features to concatenate together.
      **kwargs: base layer keyword arguments.
    """
    super().__init__(**kwargs)
    self._feature_names = feature_names

    # Validate feature names.
    if not feature_names:
      raise ValueError(
          "feature_names must be a non-empty list of strings but got"
          f" {feature_names} instead."
      )
    if not all(isinstance(name, str) for name in feature_names):
      raise TypeError(
          "feature_names must be a list of strings, but got types"
          f" {list(map(type, feature_names))}"
      )

  def build(self, input_shapes: Mapping[str, tf.TensorShape]) -> None:
    missing_features = set(self._feature_names) - input_shapes.keys()
    if missing_features:
      raise ValueError(f"Layer inputs is missing features: {missing_features}")

    feature_shapes = {
        feature_name: tensor_shape
        for feature_name, tensor_shape in input_shapes.items()
        if feature_name in self._feature_names

View on GitHub (pinned to e006f5f0d5)

When it happens

Trigger: Thrown at official/recommendation/uplift/layers/encoders/concat_features.py:46 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/bbad34e873bf7a88. Report an issue: GitHub.