{"record":{"id":"501711fff1a8eb7e","repo":"tensorflow/models","slug":"labels-should-be-of-type-bool-received-s-501711","errorCode":null,"errorMessage":"labels should be of type bool. Received: %s","messagePattern":"labels 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":241,"sourceCode":"      labels: boolean tensor of shape [N] denoting positive(=True) and negative\n        (=False) examples.\n      scope: name scope.\n\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(","sourceCodeStart":223,"sourceCodeEnd":259,"githubUrl":"https://github.com/tensorflow/models/blob/e006f5f0d534913e49c1f1dae87364039fa607e2/official/vision/utils/object_detection/balanced_positive_negative_sampler.py#L223-L259","documentation":"Error \"labels should be of type bool. Received: %s\" thrown in tensorflow/models.","triggerScenarios":"Thrown at official/vision/utils/object_detection/balanced_positive_negative_sampler.py:241 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Cast labels to tf.bool before sampling.","Compare labels against a threshold to produce 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"}