{"record":{"id":"1b26d923858dabb3","repo":"tensorflow/models","slug":"is-treatment-tensor-must-be-a-tensor-of-shape-d0","errorCode":null,"errorMessage":"is_treatment tensor must be a tensor of shape (D0,) (D0, 1) but got a tensor of shape {is_treatment.shape} instead.","messagePattern":"is_treatment tensor must be a tensor of shape \\(D0,\\) \\(D0, 1\\) but got a tensor of shape (.+?) instead\\.","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"official/recommendation/uplift/utils.py","lineNumber":55,"sourceCode":"\ndef split_by_treatment(\n    values: tf.Tensor, is_treatment: tf.Tensor\n) -> Tuple[tf.Tensor, tf.Tensor]:\n  \"\"\"Splits a tensor into control and treatment tensors.\n\n  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.","sourceCodeStart":37,"sourceCodeEnd":73,"githubUrl":"https://github.com/tensorflow/models/blob/e006f5f0d534913e49c1f1dae87364039fa607e2/official/recommendation/uplift/utils.py#L37-L73","documentation":"Error \"is_treatment tensor must be a tensor of shape (D0,) (D0, 1) but got a tensor of shape {is_treatment.shape} instead.\" thrown in tensorflow/models.","triggerScenarios":"Thrown at official/recommendation/uplift/utils.py:55 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"}