Repository navigation
Conversation
SingleClassGaussian.fit passed device= to torch.mean, which raises a TypeError, so DFM with score_type=nll could not finish fitting. Signed-off-by: sohailshk <122166523+sohailshk@users.noreply.github.com>
sohailshk
requested review from
ashwinvaidya17,
rajeshgangireddy and
samet-akcay
as code owners
November 13, 2026 19:15
Signed-off-by: sohailshk <122166523+sohailshk@users.noreply.github.com>
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
📝 Description
DFMwithscore_type="nll"cannot finish training. At the end of fitting,SingleClassGaussian.fitcallstorch.mean(dataset, dim=1, device=dataset.device), andtorch.meanhas nodeviceargument:Reproduced on main with
DFMModel(backbone="resnet18", layer="layer3", pre_trained=False, score_type="nll"): forward a few training batches, thenfit(). The fix drops thedeviceargument (the mean already lives on the dataset's device).The tests fit
SingleClassGaussiandirectly and run theDFMModeltrain,fit(), eval flow withpre_trained=False(no download) on random images; both fail on main with the TypeError.Note: correct NLL scores also need the PCA centering fix in #3920, which stops
PCA.fitcentering the memory bank in place beforetransformsubtracts the mean again.✨ Changes
✅ Checklist
Checks run:
pytest tests/unit/models/image/dfm(2 passed; both fail on main),ruff checkandruff format --check(0.12.0),mypy(1.16.1) on torch_model.py. Not run: the full suite, MVTec runs.