{"record":{"id":"07218c9be7e03871","repo":"tensorflow/models","slug":"indicator-should-be-of-type-bool-received-s-07218c","errorCode":null,"errorMessage":"indicator should be of type bool. Received: %s","messagePattern":"indicator should be of type bool\\. Received: (.+?)","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"official/vision/utils/object_detection/balanced_positive_negative_sampler.py","lineNumber":244,"sourceCode":"\n    Returns:\n      sampled_idx_indicator: boolean tensor of shape [N], True for entries which\n        are sampled.\n\n    Raises:\n      ValueError: if labels and indicator are not 1D boolean tensors.\n    \"\"\"\n    if len(indicator.get_shape().as_list()) != 1:\n      raise ValueError('indicator must be 1 dimensional, got a tensor of '\n                       'shape %s' % indicator.get_shape())\n    if len(labels.get_shape().as_list()) != 1:\n      raise ValueError('labels must be 1 dimensional, got a tensor of '\n                       'shape %s' % labels.get_shape())\n    if labels.dtype != tf.bool:\n      raise ValueError('labels should be of type bool. Received: %s' %\n                       labels.dtype)\n    if indicator.dtype != tf.bool:\n      raise ValueError('indicator should be of type bool. Received: %s' %\n                       indicator.dtype)\n    scope = scope or 'BalancedPositiveNegativeSampler'\n    with tf.name_scope(scope):\n      if self._is_static:\n        return self._static_subsample(indicator, batch_size, labels)\n\n      else:\n        # Only sample from indicated samples\n        negative_idx = tf.logical_not(labels)\n        positive_idx = tf.logical_and(labels, indicator)\n        negative_idx = tf.logical_and(negative_idx, indicator)\n\n        # Sample positive and negative samples separately\n        if batch_size is None:\n          max_num_pos = tf.reduce_sum(\n              input_tensor=tf.cast(positive_idx, dtype=tf.int32))\n        else:\n          max_num_pos = tf.cast(","sourceCodeStart":226,"sourceCodeEnd":262,"githubUrl":"https://github.com/tensorflow/models/blob/e006f5f0d534913e49c1f1dae87364039fa607e2/official/vision/utils/object_detection/balanced_positive_negative_sampler.py#L226-L262","documentation":"Error \"indicator should be of type bool. Received: %s\" thrown in tensorflow/models.","triggerScenarios":"Thrown at official/vision/utils/object_detection/balanced_positive_negative_sampler.py:244 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Cast indicator to tf.bool before sampling.","Build the indicator with a comparison (e.g. match > 0) to get a boolean tensor."],"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"}