{"record":{"id":"8ea10fc321332531","repo":"tensorflow/models","slug":"rate-must-be-a-scalar-tensor-or-a-float-in-the-ran","errorCode":null,"errorMessage":"rate must be a scalar tensor or a float in the range [0, 1), got %g","messagePattern":"rate must be a scalar tensor or a float in the range \\[0, 1\\), got %g","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"official/projects/bigbird/stateless_dropout.py","lineNumber":94,"sourceCode":"      randomly generated keep/drop flags.\n    name: A name for this operation (optional).\n\n  Returns:\n    A `Tensor` of the same shape of `x`.\n\n  Raises:\n    ValueError: If `rate` is not in `[0, 1)` or if `x` is not a floating point\n      tensor. `rate=1` is disallowed, because the output would be all zeros,\n      which is likely not what was intended.\n  \"\"\"\n  with tf.name_scope(name or 'stateless_dropout') as name:\n    x = tf.convert_to_tensor(x, name='x')\n    if not x.dtype.is_floating:\n      raise ValueError('x has to be a floating point tensor since it\\'s going '\n                       ' to be scaled. Got a %s tensor instead.' % x.dtype)\n    if isinstance(rate, numbers.Real):\n      if not (rate >= 0 and rate < 1):\n        raise ValueError('rate must be a scalar tensor or a float in the '\n                         'range [0, 1), got %g' % rate)\n      if rate > 0.5:\n        logging.log_first_n(\n            logging.WARN, 'Large dropout rate: %g (>0.5). In TensorFlow '\n            '.x, dropout() uses dropout rate instead of keep_prob. '\n            'Please ensure that this is intended.', 5, rate)\n\n    # Early return if nothing needs to be dropped.\n    if tf.get_static_value(rate) == 0:\n      return x\n\n    rate = tf.convert_to_tensor(rate, dtype=x.dtype, name='rate')\n    rate.shape.assert_has_rank(0)\n    noise_shape = _get_noise_shape(x, noise_shape)\n    # Sample a uniform distribution on [0.0, 1.0) and select values larger than\n    # rate.\n    #\n    # NOTE: Random uniform actually can only generate 2^23 floats on [1.0, 2.0)","sourceCodeStart":76,"sourceCodeEnd":112,"githubUrl":"https://github.com/tensorflow/models/blob/e006f5f0d534913e49c1f1dae87364039fa607e2/official/projects/bigbird/stateless_dropout.py#L76-L112","documentation":"Error \"rate must be a scalar tensor or a float in the range [0, 1), got %g\" thrown in tensorflow/models.","triggerScenarios":"Thrown at official/projects/bigbird/stateless_dropout.py:94 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"}