{"record":{"id":"3c48e9081386de56","repo":"tensorflow/models","slug":"values-and-is-treatment-must-be-tensors-of-shapes","errorCode":null,"errorMessage":"values and is_treatment must be tensors of shapes (D0, D1, ..., DN) and (D0, 1) (or (D0,)), but got tensors of shapes {values.shape} and {is_treatment.shape} respectively.","messagePattern":"values and is_treatment must be tensors of shapes \\(D0, D1, \\.\\.\\., DN\\) and \\(D0, 1\\) \\(or \\(D0,\\)\\), but got tensors of shapes (.+?) and (.+?) respectively\\.","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"official/recommendation/uplift/utils.py","lineNumber":61,"sourceCode":"  Args:\n    values: a `tf.Tensor` of shape (D0, D1, ..., DN).\n    is_treatment: a `tf.Tensor` of shape (D0,) or (D0, 1) castable to boolean\n      indicating if the example belongs to the treatment group (True) or control\n      group (False).\n\n  Returns:\n    A tuple with control and treatment values sliced by the is_treatment tensor.\n  \"\"\"\n  if is_treatment.shape.rank > 2 or (\n      is_treatment.shape == 2 and is_treatment.shape[1] != 1  # pyrefly: ignore[unsupported-operation]\n  ):\n    raise ValueError(\n        \"is_treatment tensor must be a tensor of shape (D0,) (D0, 1) but got a\"\n        f\" tensor of shape {is_treatment.shape} instead.\"\n    )\n\n  if values.shape[0] != is_treatment.shape[0]:\n    raise ValueError(\n        \"values and is_treatment must be tensors of shapes (D0, D1, ..., DN)\"\n        f\" and (D0, 1) (or (D0,)), but got tensors of shapes {values.shape} and\"\n        f\" {is_treatment.shape} respectively.\"\n    )\n\n  if is_treatment.dtype == tf.string:\n    raise ValueError(\n        \"is_treatment must be a tensor castable to boolean but got tensor\"\n        f\" {is_treatment} of dtype {is_treatment.dtype} instead.\"\n    )\n\n  # Assert is_treatment tensor containss only 0 or 1 values.\n  if is_treatment.dtype != tf.bool:\n    is_treatment_float = tf.cast(is_treatment, tf.float32)\n    tf.debugging.assert_equal(\n        tf.reduce_all(\n            tf.logical_or(is_treatment_float == 1.0, is_treatment_float == 0.0)\n        ),","sourceCodeStart":43,"sourceCodeEnd":79,"githubUrl":"https://github.com/tensorflow/models/blob/e006f5f0d534913e49c1f1dae87364039fa607e2/official/recommendation/uplift/utils.py#L43-L79","documentation":"Error \"values and is_treatment must be tensors of shapes (D0, D1, ..., DN) and (D0, 1) (or (D0,)), but got tensors of shapes {values.shape} and {is_treatment.shape} respectively.\" thrown in tensorflow/models.","triggerScenarios":"Thrown at official/recommendation/uplift/utils.py:61 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"e006f5f0d534913e49c1f1dae87364039fa607e2","analyzedAt":"2026-08-24T14:09:15.576Z","schemaVersion":2},"datasetVersion":"2026-08-24T17:17:21.512Z"}