{"record":{"id":"432cfc34d50f3722","repo":"tensorflow/models","slug":"initial-drop-rate-must-be-within-0-and-1","errorCode":null,"errorMessage":"Initial drop rate must be within 0 and 1.","messagePattern":"Initial drop rate must be within 0 and 1\\.","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"official/vision/modeling/layers/nn_layers.py","lineNumber":219,"sourceCode":"    x = self._activation_fn(self._se_reduce(x))\n    x = self._gating_activation_fn(self._se_expand(x))\n    return x * inputs\n\n\ndef get_stochastic_depth_rate(init_rate, i, n):\n  \"\"\"Get drop connect rate for the ith block.\n\n  Args:\n    init_rate: A `float` of initial drop rate.\n    i: An `int` of order of the current block.\n    n: An `int` total number of blocks.\n\n  Returns:\n    Drop rate of the ith block.\n  \"\"\"\n  if init_rate is not None:\n    if init_rate < 0 or init_rate > 1:\n      raise ValueError('Initial drop rate must be within 0 and 1.')\n    rate = init_rate * float(i) / n\n  else:\n    rate = None\n  return rate\n\n\n@tf_keras.utils.register_keras_serializable(package='Vision')\nclass StochasticDepth(tf_keras.layers.Layer):\n  \"\"\"Creates a stochastic depth layer.\"\"\"\n\n  def __init__(self, stochastic_depth_drop_rate, **kwargs):\n    \"\"\"Initializes a stochastic depth layer.\n\n    Args:\n      stochastic_depth_drop_rate: A `float` of drop rate.\n      **kwargs: Additional keyword arguments to be passed.\n\n    Returns:","sourceCodeStart":201,"sourceCodeEnd":237,"githubUrl":"https://github.com/tensorflow/models/blob/e006f5f0d534913e49c1f1dae87364039fa607e2/official/vision/modeling/layers/nn_layers.py#L201-L237","documentation":"Error \"Initial drop rate must be within 0 and 1.\" thrown in tensorflow/models.","triggerScenarios":"Thrown at official/vision/modeling/layers/nn_layers.py:219 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Set the initial drop rate to a value in [0, 1].","Check the stochastic depth drop rate config for an out-of-range value."],"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"}