{"record":{"id":"b5dbe6c289c8c31a","repo":"tensorflow/models","slug":"positive-fraction-should-be-in-range-0-1-receiv","errorCode":null,"errorMessage":"positive_fraction should be in range [0,1]. Received: %s.","messagePattern":"positive_fraction should be in range \\[0,1\\]\\. Received: (.+?)\\.","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"official/vision/ops/sampling_ops.py","lineNumber":134,"sourceCode":"                      tf.stack(indices_shape + params_shape[1:]))\n\n\nclass BalancedPositiveNegativeSampler:\n  \"\"\"Subsamples minibatches to a desired balance of positives and negatives.\"\"\"\n\n  def __init__(self, positive_fraction=0.5, is_static=False):\n    \"\"\"Constructs a minibatch sampler.\n\n    Args:\n      positive_fraction: desired fraction of positive examples (scalar in [0,1])\n        in the batch.\n      is_static: If True, uses an implementation with static shape guarantees.\n\n    Raises:\n      ValueError: if positive_fraction < 0, or positive_fraction > 1\n    \"\"\"\n    if positive_fraction < 0 or positive_fraction > 1:\n      raise ValueError('positive_fraction should be in range [0,1]. '\n                       'Received: %s.' % positive_fraction)\n    self._positive_fraction = positive_fraction\n    self._is_static = is_static\n\n  @staticmethod\n  def subsample_indicator(indicator, num_samples):\n    \"\"\"Subsample indicator vector.\n\n    Given a boolean indicator vector with M elements set to `True`, the function\n    assigns all but `num_samples` of these previously `True` elements to\n    `False`. If `num_samples` is greater than M, the original indicator vector\n    is returned.\n\n    Args:\n      indicator: a 1-dimensional boolean tensor indicating which elements\n        are allowed to be sampled and which are not.\n      num_samples: int32 scalar tensor\n","sourceCodeStart":116,"sourceCodeEnd":152,"githubUrl":"https://github.com/tensorflow/models/blob/e006f5f0d534913e49c1f1dae87364039fa607e2/official/vision/ops/sampling_ops.py#L116-L152","documentation":"Error \"positive_fraction should be in range [0,1]. Received: %s.\" thrown in tensorflow/models.","triggerScenarios":"Thrown at official/vision/ops/sampling_ops.py:134 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Set positive_fraction to a value within [0, 1].","Fix the sampler config; typical values are around 0.5."],"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"}