tensorflow/models · error · ValueError

When not using a bias the b_init must be None.

Error message

When not using a bias the b_init must be None.

What it means

Error "When not using a bias the b_init must be None." thrown in tensorflow/models.

Source

Thrown at official/nlp/modeling/models/t5.py:259

  """Linear module, optionally including bias."""

  def __init__(self,
               in_features: int,
               out_features: int,
               use_bias: bool = True,
               w_init: Optional[Initializer] = None,
               b_init: Optional[Initializer] = None,
               **kwargs):
    """Constructs a `Linear` module."""
    super().__init__(**kwargs)
    self.in_features = in_features
    self.out_features = out_features
    self.use_bias = use_bias
    self.w_init = w_init
    if self.use_bias:
      self.b_init = b_init if b_init else tf_keras.initializers.Zeros()
    elif b_init is not None:
      raise ValueError("When not using a bias the b_init must be None.")

    with self.name_scope:
      if self.w_init is None:
        stddev = 1 / math.sqrt(self.in_features)
        self.w_init = tf_keras.initializers.HeNormal()

      self.w = self.create_variable(
          "kernel", [self.in_features, self.out_features],
          initializer=self.w_init,
          dtype=self.dtype)

      if self.use_bias:
        self.b = self.create_variable(
            "bias", [self.out_features],
            initializer=self.b_init,
            dtype=self.dtype)

  @tf.Module.with_name_scope

View on GitHub (pinned to e006f5f0d5)

When it happens

Trigger: Thrown at official/nlp/modeling/models/t5.py:259 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/3081d06d590107ee. Report an issue: GitHub.