Skip to content

PyTorch training metrics incorrectly use multi-animal evaluation for single-animal projects #3518

Description

@Fabian97-Bumbee

Is there an existing issue for this?

  • I have searched the existing issues

Operating System

Windows (CPU)

DeepLabCut version

3.0.1

What engine are you using?

pytorch

DeepLabCut mode

single animal

Device type

CPU - Intel Core i5 14500
UHD Graphics 770

Bug description 🐛

Single-Animal Metric Evaluation Bug.pdf

Steps To Reproduce

Steps To Reproduce.pdf

Relevant log output

Training learning_stats.csv:

metrics/test.rmse,NaN
metrics/test.rmse_pcutoff,NaN
metrics/test.mAP,0
metrics/test.mAR,0

Direct evaluation of the same snapshot:

rmse              : 1.4092687927219225
rmse_pcutoff      : 1.33179851501842
mAP               : 0
mAR               : 0

Direct metric calculation with the same test data:

single_animal=True
rmse              : 1.4092687927219225
rmse_pcutoff      : 1.33179851501842

The project contains 33 test images, with valid ground-truth and prediction arrays of shape (1, 1, 3).

Anything else?

Anything else.pdf

Code of Conduct

Activity

  1. added
    bugSomething isn't working
    performanceRelated to (poor or unexpected) performance in any context (inference, training, labeling,...)
    on Sep 15, 2026
  2. added theissue type on Sep 15, 2026
  3. added
    metricsRelated to performance reporting and metrics calculation
    and removed
    performanceRelated to (poor or unexpected) performance in any context (inference, training, labeling,...)
    on Sep 17, 2026
  4. C-Achard commented on Sep 17, 2026

    @C-Achard
    Member

    Hello @Fabian97-Bumbee,

    Thanks for opening this, and apologies for the late reply as we were focusing on the next release.
    Your diagnosis is correct, this is the result of several edge cases not being handled entirely consistently in the code.

    Note that this does not affect the actual training process in that the "latest" weights generated are still what you'd have gotten without the issue, however the "best" snapshot saved may not have been derived correctly.

    Workaround (temporary, for 3.0.1-3.0.2)

    In your project config.yaml, change:
    snapshotindex: -2 (should be -1 by default)

    This will use the most trained (latest) snapshot instead of the early mislabeled "best" one.

    This will not fix the metrics (see below for the upcoming fixes), but will at least use a model that is properly trained for the rest of your analysis. Note that after the fix is released this will no longer be appropriate and should be switched to -1 again.

    You can also still diagnose training normally, in two ways:

    • Per epoch: use learning_stats.csv in the model folder, which records losses/train.total_loss and losses/eval.total_loss for every epoch
    • Per snapshot: set snapshotindex: all (same place as before) and run Evaluate Network. The results CSV in evaluation-results-pytorch has a row per snapshot with both train and test RMSE (in pixels).

    For reference

    Regarding the current code behavior:

    After the fix is released, best snapshots can no longer be selected using invalid metrics.
    If you would like best-snapshot selection then, you can select on RMSE instead, in pytorch_config.yaml:

    runner:
      key_metric: "test.rmse"
      key_metric_asc: false
    

    Note that sadly we cannot include this in 3.0.2 so it will have to be shipped at a later time, so this will only work in a future version, not on 3.0.1/3.0.2.

    Let me know if you have any questions and thanks again!

    Best,
    Cyril

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingmetricsRelated to performance reporting and metrics calculationpytorch

Type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions