Repository navigation
Fix bedroc_score through the Metric wrapper - #5192
Open
barlowa124 wants to merge 1 commit into
Open
barlowa124 wants to merge 1 commit into
barlowa124 wants to merge 1 commit into
Conversation
Metric defaults classification metrics like bedroc_score to the 'threshold-one-hot' handling mode, which thresholds predictions into hard labels and leaves labels one-hot encoded. Inside bedroc_score, flatten() on the (N, 2) label array produced 2N values that zip() silently truncated against the N prediction scores, destroying the ranking: perfect and reversed rankings both scored ~0.5. Bedroc_score is a ranking metric and needs continuous scores, so it now defaults to 'direct' handling like roc_auc_score. Bedroc_score also takes the positive-class column when handed 2-D one-hot labels and asserts label/score shape agreement so truncation fails loudly instead of silently misaligning. Fixes deepchem#5191
barlowa124
force-pushed
the
bedroc-onehot-labels
branch
from
October 1, 2026 20:44
2f3c271 to
eb4ab0a
Compare
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
LinearAttentionbuilt its projection matrices insidebuild_from_inputs, which runs on the first forward call. TorchModelhas already moved the module to its device by then, so weights were
created on CPU and the first non-CPU forward failed. It also meant
model.parameters()was empty at init time, so an optimizer builtbefore the first batch never saw the projections.
The projections are now created in
__init__when the inputdimensions are known, with the lazy path retained for deferred shapes.
Weights therefore sit in
parameters()immediately and follow.to(device)like any other layer.test_linear_attention_pytorch.pygains a device-placement test.Type of change
Checklist
yapf -i <modified file>and check no errors (yapf version must be 0.32.0)mypy -p deepchemand check no errors (mypy run on modified files,--follow-imports=skip)flake8 <modified file> --countand check no errorspython -m doctest <modified file>and check no errors