Skip to content

fix a confusing message for freeze_bn_stats#3166

Merged
deruyter92 merged 2 commits intoDeepLabCut:mainfrom
Jiefei-Wang:fix
Jan 9, 2026
Merged

fix a confusing message for freeze_bn_stats#3166
deruyter92 merged 2 commits intoDeepLabCut:mainfrom
Jiefei-Wang:fix

Conversation

@Jiefei-Wang
Copy link
Copy Markdown
Contributor

This pull request fixes a very confusing message: According to your model configuration, you're training with batch size 1 and/or freeze_bn_stats=false. This is not an optimal setting if you have powerful GPUs.

The condition that triggers this message is loader.model_cfg["model"].get("freeze_bn_stats", False). Therefore, the user can see this message only when freeze_bn_stats=true. This pull request flips the boolean value to give the correct message.

if (
loader.model_cfg["model"].get("freeze_bn_stats", False)
or loader.model_cfg["model"].get("backbone", {}).get("freeze_bn_stats", False)
or batch_size == 1
):
logging.info(
"\nNote: According to your model configuration, you're training with batch "
"size 1 and/or ``freeze_bn_stats=false``. This is not an optimal setting "
"if you have powerful GPUs.\n"
"This is good for small batch sizes (e.g., when training on a CPU), where "
"you should keep ``freeze_bn_stats=true``.\n"
"If you're using a GPU to train, you can obtain faster performance by "
"setting a larger batch size (the biggest power of 2 where you don't get"
"a CUDA out-of-memory error, such as 8, 16, 32 or 64 depending on the "
"model, size of your images, and GPU memory) and ``freeze_bn_stats=false`` "
"for the backbone of your model. \n"
"This also allows you to increase the learning rate (empirically you can "
"scale the learning rate by sqrt(batch_size) times).\n"
)

@MMathisLab MMathisLab requested a review from Copilot January 9, 2026 14:49
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

Copy link
Copy Markdown
Collaborator

@deruyter92 deruyter92 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well spotted! Thanks for your contribution.

@deruyter92 deruyter92 merged commit 8fd2f05 into DeepLabCut:main Jan 9, 2026
9 of 10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

contributions-welcome documentation documentation updates/comments

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants