tensorflow/models · error · ValueError

The control logits and treatment logits computed by the cont

Error message

The control logits and treatment logits computed by the control and treatment heads must be tensors of the same shape, but got shape {control_logits.shape} for the control logits and shape {treatment_logits.shape} for the treatment logits.

What it means

Error "The control logits and treatment logits computed by the control and treatment heads must be tensors of the same shape, but got shape {control_logits.shape} for the control logits and shape {treatment_logits.shape} for the treatment logits." thrown in tensorflow/models.

Source

Thrown at official/recommendation/uplift/layers/heads/two_tower_logits_head.py:156

          ),
      )
    super().build(input_shapes)

  def call(
      self, inputs: tuple[tf.Tensor, tf.Tensor]
  ) -> tuple[tf.Tensor, tf.Tensor]:
    control_embedding, treatment_embedding = inputs

    if self._layering_config.layering_method == LayeringMethod.LINEAR_LAYERING:
      treatment_embedding += self._linear_layering(
          tf.stop_gradient(control_embedding)
      )

    control_logits = self._control_head(control_embedding)
    treatment_logits = self._treatment_head(treatment_embedding)

    if control_logits.shape != treatment_logits.shape:
      raise ValueError(
          "The control logits and treatment logits computed by the control and"
          " treatment heads must be tensors of the same shape, but got shape"
          f" {control_logits.shape} for the control logits and shape"
          f" {treatment_logits.shape} for the treatment logits."
      )

    if self._layering_config.layering_method == LayeringMethod.LOGIT_SUM:
      treatment_logits += tf.stop_gradient(control_logits)

    return control_logits, treatment_logits

  def get_config(self) -> dict[str, Any]:
    config = super().get_config()
    config["layering_config"] = dataclasses.asdict(self._layering_config)

    for layer_name, layer in (
        ("control_head", self._control_head),
        ("treatment_head", self._treatment_head),

View on GitHub (pinned to e006f5f0d5)

When it happens

Trigger: Thrown at official/recommendation/uplift/layers/heads/two_tower_logits_head.py:156 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/e9568f4756c97ee2. Report an issue: GitHub.