tensorflow/models · error · ValueError

Bad conversion, model outputs do not match.

Error message

Bad conversion, model outputs do not match.

What it means

Raised after --verify_output when the converted (2+1)D MoViNet's logits diverge from the original 3D model on the same random input, meaning the weight transplant in the conversion script produced a functionally different model.

Solutions

  1. Re-run conversion and confirm every 3D kernel was correctly split/transposed (check depthwise kernel transposition branch)
  2. Verify you are converting a supported MoViNet version and that model_2plus1d was built with matching architecture params
  3. Diff set_weights input shapes against model_3d_2plus1d weights layer by layer
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at official/projects/movinet/tools/convert_3d_2plus1d.py:98 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/cd51ea34f3b99250. Report an issue: GitHub.

Appendix: source

Thrown at official/projects/movinet/tools/convert_3d_2plus1d.py:98

    else:
      if var_3d_2plus1d.shape[0] == 1:
        weight = var_3d_2plus1d[0]
      else:
        weight = var_3d_2plus1d[:, 0]
      if weight.shape[-1] != var_2plus1d.shape[-1]:
        # Transpose any depthwise kernels (conv3d --> depthwise_conv2d)
        weight = tf.transpose(weight, perm=(0, 1, 3, 2))
      weights.append(weight)
  model_2plus1d.set_weights(weights)

  if FLAGS.verify_output:
    inputs = tf.random.uniform([1, 6, 64, 64, 3], dtype=tf.float32)

    logits_2plus1d = model_2plus1d(inputs)
    logits_3d_2plus1d = model_3d_2plus1d(inputs)

    if tf.reduce_mean(logits_2plus1d - logits_3d_2plus1d) > 1e-5:
      raise ValueError('Bad conversion, model outputs do not match.')

  save_checkpoint = tf.train.Checkpoint(
      model=model_2plus1d, backbone=backbone_2plus1d)
  save_checkpoint.save(FLAGS.output_checkpoint_path)


if __name__ == '__main__':
  flags.mark_flag_as_required('input_checkpoint_path')
  flags.mark_flag_as_required('output_checkpoint_path')
  app.run(main)

View on GitHub (pinned to e006f5f0d5)