This issue is part of a Codex global repository scan.
Problem:
In EigLoss.forward, loss is assigned only if mask_in contains at least one selected value. If the configured energy window excludes all selected bands but mask_out contains entries, the code evaluates loss + ... before loss exists.
Code reference:
https://github.com/deepmodeling/deeptb/blob/86c60c73996f0dd961c3138f2e88424382cb734e/dptb/nnops/loss.py#L215-L219
Impact:
Valid narrow-window configurations can fail with UnboundLocalError during training or evaluation.
Suggested fix:
Initialize loss before the mask branches, or compute in-window and out-of-window terms independently before summing the terms that are present.
This issue is part of a Codex global repository scan.
Problem:
In
EigLoss.forward,lossis assigned only ifmask_incontains at least one selected value. If the configured energy window excludes all selected bands butmask_outcontains entries, the code evaluatesloss + ...beforelossexists.Code reference:
https://github.com/deepmodeling/deeptb/blob/86c60c73996f0dd961c3138f2e88424382cb734e/dptb/nnops/loss.py#L215-L219
Impact:
Valid narrow-window configurations can fail with
UnboundLocalErrorduring training or evaluation.Suggested fix:
Initialize
lossbefore the mask branches, or compute in-window and out-of-window terms independently before summing the terms that are present.