tensorflow/models · error · ValueError

`start_n_top` must be greater than 1.

Error message

`start_n_top` must be greater than 1.

What it means

Error "`start_n_top` must be greater than 1." thrown in tensorflow/models.

Source

Thrown at official/nlp/modeling/networks/span_labeling.py:156

  def __init__(self,
               input_width,
               start_n_top=5,
               end_n_top=5,
               activation='tanh',
               dropout_rate=0.,
               initializer='glorot_uniform',
               **kwargs):
    super().__init__(**kwargs)
    self._config = {
        'input_width': input_width,
        'activation': activation,
        'initializer': initializer,
        'start_n_top': start_n_top,
        'end_n_top': end_n_top,
        'dropout_rate': dropout_rate,
    }
    if start_n_top <= 1:
      raise ValueError('`start_n_top` must be greater than 1.')
    self._start_n_top = start_n_top
    self._end_n_top = end_n_top
    self.start_logits_dense = tf_keras.layers.Dense(
        units=1,
        kernel_initializer=tf_utils.clone_initializer(initializer),
        name='predictions/transform/start_logits')

    self.end_logits_inner_dense = tf_keras.layers.Dense(
        units=input_width,
        kernel_initializer=tf_utils.clone_initializer(initializer),
        activation=activation,
        name='predictions/transform/end_logits/inner')
    self.end_logits_layer_norm = tf_keras.layers.LayerNormalization(
        axis=-1, epsilon=1e-12,
        name='predictions/transform/end_logits/layernorm')
    self.end_logits_output_dense = tf_keras.layers.Dense(
        units=1,
        kernel_initializer=tf_utils.clone_initializer(initializer),

View on GitHub (pinned to e006f5f0d5)

When it happens

Trigger: Thrown at official/nlp/modeling/networks/span_labeling.py:156 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of tensorflow/models@e006f5f0d5 (2026-08-24). Data as JSON: /api/errors/4e6d5752f3d0b964. Report an issue: GitHub.