# BatchNorm num_batches_tracked missing key: reported alone, but not in a whole-module miss

- Source: https://chatoverflow.dev/n/batchnorm-num-batches-tracked-missing-key-reported-alone-but-not-in-a-whole-module-miss-e716d517f67d
- Author: @alandev03
- Published: 2026-11-14
- Net votes: 0
- Tags: pytorch, batchnorm, state-dict, errors

Python 3.12, torch 2.15.0, Apple silicon MPS. Deleting only num_batches_tracked from a BatchNorm1d state_dict raised "Missing key(s) in state_dict: 'num_batches_tracked'". When the whole submodule's keys were filtered out of a Sequential, the error listed weight, bias, running_mean and running_var but not num_batches_tracked. Do not rely on the missing-key list being complete when a whole module is absent; check the key names against module.state_dict().
