{"record":{"id":"e6aebd015cc88008","repo":"tensorflow/models","slug":"indicator-must-be-static-in-shape-when-is-static-i-e6aebd","errorCode":null,"errorMessage":"indicator must be static in shape when is_static isTrue","messagePattern":"indicator must be static in shape when is_static isTrue","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"official/vision/utils/object_detection/balanced_positive_negative_sampler.py","lineNumber":144,"sourceCode":"    Args:\n      indicator: boolean tensor of shape [N] whose True entries can be sampled.\n        N should be a complie time constant.\n      batch_size: desired batch size. This scalar cannot be None.\n      labels: boolean tensor of shape [N] denoting positive(=True) and negative\n        (=False) examples. N should be a complie time constant.\n\n    Returns:\n      sampled_idx_indicator: boolean tensor of shape [N], True for entries which\n        are sampled. It ensures the length of output of the subsample is always\n        batch_size, even when number of examples set to True in indicator is\n        less than batch_size.\n\n    Raises:\n      ValueError: if labels and indicator are not 1D boolean tensors.\n    \"\"\"\n    # Check if indicator and labels have a static size.\n    if not indicator.shape.is_fully_defined():\n      raise ValueError('indicator must be static in shape when is_static is'\n                       'True')\n    if not labels.shape.is_fully_defined():\n      raise ValueError('labels must be static in shape when is_static is'\n                       'True')\n    if not isinstance(batch_size, int):\n      raise ValueError('batch_size has to be an integer when is_static is'\n                       'True.')\n\n    input_length = tf.shape(input=indicator)[0]\n\n    # Set the number of examples set True in indicator to be at least\n    # batch_size.\n    num_true_sampled = tf.reduce_sum(\n        input_tensor=tf.cast(indicator, tf.float32))\n    additional_false_sample = tf.less_equal(\n        tf.cumsum(tf.cast(tf.logical_not(indicator), tf.float32)),\n        batch_size - num_true_sampled)\n    indicator = tf.logical_or(indicator, additional_false_sample)","sourceCodeStart":126,"sourceCodeEnd":162,"githubUrl":"https://github.com/tensorflow/models/blob/e006f5f0d534913e49c1f1dae87364039fa607e2/official/vision/utils/object_detection/balanced_positive_negative_sampler.py#L126-L162","documentation":"Error \"indicator must be static in shape when is_static isTrue\" thrown in tensorflow/models.","triggerScenarios":"Thrown at official/vision/utils/object_detection/balanced_positive_negative_sampler.py:144 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Provide an indicator tensor with a fully static shape when is_static=True.","Set is_static=False if shapes are dynamic, or fix the indicator shape with set_shape."],"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"}