{"record":{"id":"d9b9a8ec3e98307e","repo":"tensorflow/models","slug":"the-input-size-d-is-not-a-multiple-of-the-numbe-d9b9a8","errorCode":null,"errorMessage":"The input size (%d) is not a multiple of the number of attention heads (%d)","messagePattern":"The input size \\((.+?)\\) is not a multiple of the number of attention heads \\((.+?)\\)","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"official/nlp/modeling/layers/transformer_scaffold.py","lineNumber":143,"sourceCode":"    self._bias_constraint = tf_keras.constraints.get(bias_constraint)\n\n  def build(self, input_shape):\n    if isinstance(input_shape, tf.TensorShape):\n      input_tensor_shape = input_shape\n    elif isinstance(input_shape, (list, tuple)):\n      input_tensor_shape = tf.TensorShape(input_shape[0])\n    else:\n      raise ValueError(\n          \"The type of input shape argument is not supported, got: %s\" %\n          type(input_shape))\n\n    if len(input_tensor_shape.as_list()) != 3:\n      raise ValueError(\n          \"TransformerScaffold expects a three-dimensional input of \"\n          \"shape [batch, sequence, width].\")\n    hidden_size = input_tensor_shape[-1]\n    if hidden_size % self._num_heads != 0:\n      raise ValueError(\n          \"The input size (%d) is not a multiple of the number of attention \"\n          \"heads (%d)\" % (hidden_size, self._num_heads))\n    self._attention_head_size = int(hidden_size // self._num_heads)\n\n    common_kwargs = dict(\n        kernel_regularizer=self._kernel_regularizer,\n        bias_regularizer=self._bias_regularizer,\n        activity_regularizer=self._activity_regularizer,\n        kernel_constraint=self._kernel_constraint,\n        bias_constraint=self._bias_constraint)\n\n    def get_layer_instance(instance_or_cls, config, default_config):\n      if isinstance(instance_or_cls, tf_keras.layers.Layer):\n        return instance_or_cls\n      elif isinstance(instance_or_cls, dict):\n        return get_layer_instance(\n            tf_keras.utils.deserialize_keras_object(instance_or_cls),\n            config,","sourceCodeStart":125,"sourceCodeEnd":161,"githubUrl":"https://github.com/tensorflow/models/blob/e006f5f0d534913e49c1f1dae87364039fa607e2/official/nlp/modeling/layers/transformer_scaffold.py#L125-L161","documentation":"Error \"The input size (%d) is not a multiple of the number of attention heads (%d)\" thrown in tensorflow/models.","triggerScenarios":"Thrown at official/nlp/modeling/layers/transformer_scaffold.py:143 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"}