Skip to content

fix: give skorch classifiers in an L-C2ST ensemble float labels - #2166

Draft
manuelgloeckler wants to merge 1 commit into
mainfrom
fix/lc2st-skorch-ensemble
Draft

manuelgloeckler wants to merge 1 commit into
mainfrom
fix/lc2st-skorch-ensemble

Conversation

@manuelgloeckler

Copy link
Copy Markdown
Contributor

Split out of the Simformer PR (#1621). The fix isn't Simformer-specific. The fix is by @nMaax, who is credited as co-author on the commit.

Problem

With num_ensemble > 1, train_lc2st receives an EnsembleClassifier wrapper. Its check for a skorch classifier, isinstance(clf, NeuralNetBinaryClassifier), never matches the wrapper, so a skorch classifier gets int64 labels. BCEWithLogitsLoss needs float labels, so training fails:

RuntimeError: result type Float can't be cast to the desired output type Long

This affects classifier="mlp" on a GPU with num_ensemble > 1, and any skorch NeuralNetBinaryClassifier passed with num_ensemble > 1.

Fix

Check the classifier the ensemble wraps (EnsembleClassifier.clf).

#1621 also re-seeded the global torch/numpy RNG for ensemble members that have no random_state. That change is left out on purpose: test_lc2st_null_training_leaves_global_rng_untouched requires that L-C2ST leaves the global RNG alone, and members are already reproducible under the caller's seed.

Testing

test_lc2st_skorch_ensemble_trains fails on main with the error above and passes with the fix. tests/lc2st_test.py passes.

🤖 Generated with Claude Code

With num_ensemble > 1, train_lc2st receives an EnsembleClassifier, so the
skorch check never matched and BCEWithLogitsLoss got int64 labels. Check
the wrapped classifier instead.

Co-authored-by: nMaax <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
@coderabbitai

coderabbitai Bot commented Nov 11, 2026

Copy link
Copy Markdown

Important

Draft PR not reviewed

Draft PRs are not automatically reviewed by default.

  • Trigger a manual review

To automatically review draft PRs, update your CodeRabbit configuration:

reviews:
  auto_review:
    drafts: true
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@manuelgloeckler manuelgloeckler mentioned this pull request Nov 11, 2026

This branch has not been deployed

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant