tensorflow/models · error · ValueError

Number of elements in `temporal_kernel_sizes` must equal to

Error message

Number of elements in `temporal_kernel_sizes` must equal to `block_repeats`.

What it means

Error "Number of elements in `temporal_kernel_sizes` must equal to `block_repeats`." thrown in tensorflow/models.

Source

Thrown at official/vision/modeling/backbones/resnet_3d.py:325

      temporal_kernel_sizes: A tuple that specifies the temporal kernel sizes
        for each block in the current group.
      temporal_strides: An `int` of temporal strides for the first convolution
        in this group.
      spatial_strides: An `int` stride to use for the first convolution of the
        layer. If greater than 1, this layer will downsample the input.
      block_fn: Either `nn_blocks.ResidualBlock` or `nn_blocks.BottleneckBlock`.
      block_repeats: An `int` of number of blocks contained in the layer.
      stochastic_depth_drop_rate: A `float` of drop rate of the current block
        group.
      use_self_gating: A `bool` that specifies whether to apply self-gating
        module or not.
      name: A `str` name for the block.

    Returns:
      The output `tf.Tensor` of the block layer.
    """
    if len(temporal_kernel_sizes) != block_repeats:
      raise ValueError(
          'Number of elements in `temporal_kernel_sizes` must equal to `block_repeats`.'
      )

    # Only apply self-gating module in the last block.
    use_self_gating_list = [False] * (block_repeats - 1) + [use_self_gating]

    x = block_fn(
        filters=filters,
        temporal_kernel_size=temporal_kernel_sizes[0],
        temporal_strides=temporal_strides,
        spatial_strides=spatial_strides,
        stochastic_depth_drop_rate=stochastic_depth_drop_rate,
        use_self_gating=use_self_gating_list[0],
        se_ratio=self._se_ratio,
        kernel_initializer=self._kernel_initializer,
        kernel_regularizer=self._kernel_regularizer,
        bias_regularizer=self._bias_regularizer,
        activation=self._activation,

View on GitHub (pinned to e006f5f0d5)

Solutions

  1. Set temporal_kernel_sizes to a list whose length equals block_repeats for that stage.
  2. Provide one temporal kernel size per repeated block, or None to use the default.

When it happens

Trigger: Thrown at official/vision/modeling/backbones/resnet_3d.py:325 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/67a3082d74018692. Report an issue: GitHub.