{"record":{"id":"b441ad5e4a99d089","repo":"tensorflow/models","slug":"the-width-of-the-input-tensor-input-width-hid-b441ad","errorCode":null,"errorMessage":"The width of the input tensor {input_width} != hidden size {self.hidden_size}","messagePattern":"The width of the input tensor (.+?) != hidden size (.+?)","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"official/projects/qat/nlp/modeling/layers/mobile_bert_layers.py","lineNumber":421,"sourceCode":"    Args:\n      input_tensor: Float tensor of shape `(batch_size, seq_length,\n        hidden_size)`.\n      attention_mask: (optional) int32 tensor of shape `(batch_size, seq_length,\n        seq_length)`, with 1 for positions that can be attended to and 0 in\n        positions that should not be.\n      return_attention_scores: If return attention score.\n\n    Returns:\n      layer_output: Float tensor of shape\n        `(batch_size, seq_length, hidden_size)`.\n      attention_scores (Optional): Only when return_attention_scores is True.\n\n    Raises:\n      ValueError: A Tensor shape or parameter is invalid.\n    \"\"\"\n    input_width = input_tensor.shape.as_list()[-1]\n    if input_width != self.hidden_size:\n      raise ValueError(\n          (f'The width of the input tensor {input_width} != '\n           f'hidden size {self.hidden_size}'))\n\n    prev_output = input_tensor\n    # input bottleneck\n    dense_layer = self.block_layers['bottleneck_input'][0]\n    layer_norm = self.block_layers['bottleneck_input'][1]\n    layer_input = dense_layer(prev_output)\n    layer_input = layer_norm(layer_input)\n\n    if self.use_bottleneck_attention:\n      key_tensor = layer_input\n      query_tensor = layer_input\n      value_tensor = layer_input\n    elif self.key_query_shared_bottleneck:\n      dense_layer = self.block_layers['kq_shared_bottleneck'][0]\n      layer_norm = self.block_layers['kq_shared_bottleneck'][1]\n      shared_attention_input = dense_layer(prev_output)","sourceCodeStart":403,"sourceCodeEnd":439,"githubUrl":"https://github.com/tensorflow/models/blob/e006f5f0d534913e49c1f1dae87364039fa607e2/official/projects/qat/nlp/modeling/layers/mobile_bert_layers.py#L403-L439","documentation":"Error \"The width of the input tensor {input_width} != hidden size {self.hidden_size}\" thrown in tensorflow/models.","triggerScenarios":"Thrown at official/projects/qat/nlp/modeling/layers/mobile_bert_layers.py:421 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"}