{"record":{"id":"8691b32d6aac64a7","repo":"tensorflow/models","slug":"max-length-must-be-an-integer-not-none","errorCode":null,"errorMessage":"`max_length` must be an Integer, not `None`.","messagePattern":"`max_length` must be an Integer, not `None`\\.","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"official/nlp/modeling/layers/position_embedding.py","lineNumber":58,"sourceCode":"    max_length: The maximum size of the dynamic sequence.\n    initializer: The initializer to use for the embedding weights. Defaults to\n      \"glorot_uniform\".\n    seq_axis: The axis of the input tensor where we add the embeddings.\n\n  Reference: This layer creates a positional embedding as described in\n  [BERT: Pre-training of Deep Bidirectional Transformers for Language\n  Understanding](https://arxiv.org/abs/1810.04805).\n  \"\"\"\n\n  def __init__(self,\n               max_length,\n               initializer=\"glorot_uniform\",\n               seq_axis=1,\n               **kwargs):\n\n    super().__init__(**kwargs)\n    if max_length is None:\n      raise ValueError(\n          \"`max_length` must be an Integer, not `None`.\"\n      )\n    self._max_length = max_length\n    self._initializer = tf_keras.initializers.get(initializer)\n    self._seq_axis = seq_axis\n\n  def get_config(self):\n    config = {\n        \"max_length\": self._max_length,\n        \"initializer\": tf_keras.initializers.serialize(self._initializer),\n        \"seq_axis\": self._seq_axis,\n    }\n    base_config = super(PositionEmbedding, self).get_config()\n    return dict(list(base_config.items()) + list(config.items()))\n\n  def build(self, input_shape):\n    dimension_list = input_shape\n    width = dimension_list[-1]","sourceCodeStart":40,"sourceCodeEnd":76,"githubUrl":"https://github.com/tensorflow/models/blob/e006f5f0d534913e49c1f1dae87364039fa607e2/official/nlp/modeling/layers/position_embedding.py#L40-L76","documentation":"Error \"`max_length` must be an Integer, not `None`.\" thrown in tensorflow/models.","triggerScenarios":"Thrown at official/nlp/modeling/layers/position_embedding.py:58 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"}