{"record":{"id":"ef393fae1adc3e90","repo":"tensorflow/models","slug":"the-passed-network-s-output-length-is-s-which-is","errorCode":null,"errorMessage":"The passed network's output length is %s, which is less than the requested num_token_predictions %s.","messagePattern":"The passed network's output length is (.+?), which is less than the requested num_token_predictions (.+?)\\.","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"official/nlp/modeling/models/bert_pretrainer.py","lineNumber":90,"sourceCode":"    network_inputs = network.inputs\n    inputs = copy.copy(network_inputs)\n\n    # Because we have a copy of inputs to create this Model object, we can\n    # invoke the Network object with its own input tensors to start the Model.\n    # Note that, because of how deferred construction happens, we can't use\n    # the copy of the list here - by the time the network is invoked, the list\n    # object contains the additional input added below.\n    sequence_output, cls_output = network(network_inputs)\n\n    # The encoder network may get outputs from all layers.\n    if isinstance(sequence_output, list):\n      sequence_output = sequence_output[-1]\n    if isinstance(cls_output, list):\n      cls_output = cls_output[-1]\n    sequence_output_length = sequence_output.shape.as_list()[1]\n    if sequence_output_length is not None and (sequence_output_length <\n                                               num_token_predictions):\n      raise ValueError(\n          \"The passed network's output length is %s, which is less than the \"\n          'requested num_token_predictions %s.' %\n          (sequence_output_length, num_token_predictions))\n\n    masked_lm_positions = tf_keras.layers.Input(\n        shape=(num_token_predictions,),\n        name='masked_lm_positions',\n        dtype=tf.int32)\n    inputs.append(masked_lm_positions)\n\n    if embedding_table is None:\n      embedding_table = network.get_embedding_table()\n    masked_lm = layers.MaskedLM(\n        embedding_table=embedding_table,\n        activation=activation,\n        initializer=tf_utils.clone_initializer(initializer),\n        output=output,\n        name='cls/predictions')","sourceCodeStart":72,"sourceCodeEnd":108,"githubUrl":"https://github.com/tensorflow/models/blob/e006f5f0d534913e49c1f1dae87364039fa607e2/official/nlp/modeling/models/bert_pretrainer.py#L72-L108","documentation":"Error \"The passed network's output length is %s, which is less than the requested num_token_predictions %s.\" thrown in tensorflow/models.","triggerScenarios":"Thrown at official/nlp/modeling/models/bert_pretrainer.py:90 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"}