tensorflow/models · error · ValueError

input_offset ({}) is larger than num feats({})

Error message

input_offset ({}) is larger than num feats({})

What it means

Error "input_offset ({}) is larger than num feats({})" thrown in tensorflow/models.

Source

Thrown at official/vision/modeling/decoders/nasfpn.py:261

      }

  def _global_attention(self, feat0, feat1):
    m = tf.math.reduce_max(feat0, axis=[1, 2], keepdims=True)
    m = tf.math.sigmoid(m)
    return feat0 + feat1 * m

  def _build_feature_pyramid(self, feats):
    num_output_connections = [0] * len(feats)
    num_output_levels = self._max_level - self._min_level + 1
    feat_levels = list(range(self._min_level, self._max_level + 1))

    for i, block_spec in enumerate(self._block_specs):
      new_level = block_spec.level

      # Checks the range of input_offsets.
      for input_offset in block_spec.input_offsets:
        if input_offset >= len(feats):
          raise ValueError(
              'input_offset ({}) is larger than num feats({})'.format(
                  input_offset, len(feats)))
      input0 = block_spec.input_offsets[0]
      input1 = block_spec.input_offsets[1]

      # Update graph with inputs.
      node0 = feats[input0]
      node0_level = feat_levels[input0]
      num_output_connections[input0] += 1
      node0 = self._resample_feature_map(node0, node0_level, new_level)
      node1 = feats[input1]
      node1_level = feat_levels[input1]
      num_output_connections[input1] += 1
      node1 = self._resample_feature_map(node1, node1_level, new_level)

      # Combine node0 and node1 to create new feat.
      if block_spec.combine_fn == 'sum':
        new_node = node0 + node1

View on GitHub (pinned to e006f5f0d5)

Solutions

  1. Set input_offset to a value smaller than the number of feature maps passed to the NASFPN layer.
  2. Pass all backbone feature levels so the configured offsets are valid.

When it happens

Trigger: Thrown at official/vision/modeling/decoders/nasfpn.py:261 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/62e0373d418bf366. Report an issue: GitHub.