{"record":{"id":"dae65bf3534fd69d","repo":"tensorflow/models","slug":"the-slicing-feature-and-slicing-values-in-slici","errorCode":null,"errorMessage":"The `slicing_feature` and slicing values in `slicing_spec` must have the same type. Got types: {(slicing_feature.dtype, self._slicing_feature_dtype)}.","messagePattern":"The `slicing_feature` and slicing values in `slicing_spec` must have the same type\\. Got types: (.+?)\\.","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"official/recommendation/uplift/metrics/sliced_metric.py","lineNumber":144,"sourceCode":"      sample_weight: tf.Tensor | None = None,\n      slicing_feature: tf.Tensor,\n      **kwargs,\n  ):\n    \"\"\"Updates the state of the metrics for each slice.\n\n    Args:\n      *args: A variable amount of `tf.Tensor` instances that will be passed to\n        the `update_state` method of each metric.\n      sample_weight: An optional `tf.Tensor` used to weight the sample. Its\n        dimensions must be broadcastable to the shape(s) of *args.\n      slicing_feature: A `tf.Tensor` consisting of the feature to be sliced on.\n        Its dimensions must be broadcastable to the shape(s) of *args.\n      **kwargs: Keyword arguments that will be passed to the `update_state`\n        method of each metric.\n    \"\"\"\n\n    if slicing_feature.dtype != self._slicing_feature_dtype:\n      raise ValueError(\n          \"The `slicing_feature` and slicing values in `slicing_spec` must \"\n          \"have the same type. Got types: \"\n          f\"{(slicing_feature.dtype, self._slicing_feature_dtype)}.\"\n      )\n\n    if sample_weight is not None:\n      for _ in range(len(slicing_feature.shape) - len(sample_weight.shape)):\n        sample_weight = tf.expand_dims(sample_weight, axis=-1)\n\n      for _ in range(len(sample_weight.shape) - len(slicing_feature.shape)):\n        slicing_feature = tf.expand_dims(slicing_feature, axis=-1)\n\n    self._metric.update_state(*args, sample_weight=sample_weight, **kwargs)\n    for slicing_val, metric in zip(\n        self._slicing_values_tensors, self._sliced_metrics\n    ):\n      slice_mask = tf.cast(slicing_feature == slicing_val, dtype=tf.float32)\n      if sample_weight is not None:","sourceCodeStart":126,"sourceCodeEnd":162,"githubUrl":"https://github.com/tensorflow/models/blob/e006f5f0d534913e49c1f1dae87364039fa607e2/official/recommendation/uplift/metrics/sliced_metric.py#L126-L162","documentation":"Error \"The `slicing_feature` and slicing values in `slicing_spec` must have the same type. Got types: {(slicing_feature.dtype, self._slicing_feature_dtype)}.\" thrown in tensorflow/models.","triggerScenarios":"Thrown at official/recommendation/uplift/metrics/sliced_metric.py:144 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"}