[BUGFIX] Fix inplace masking for AKT to prevent data leakage#53
Open
AutoVision-cloud wants to merge 1 commit intobigdata-ustc:mainfrom
Open
[BUGFIX] Fix inplace masking for AKT to prevent data leakage#53AutoVision-cloud wants to merge 1 commit intobigdata-ustc:mainfrom
AutoVision-cloud wants to merge 1 commit intobigdata-ustc:mainfrom
Conversation
Change masked_fill to masked_fill_ (in-place operation) on line 273 to prevent data leakage from future time steps. The non-in-place version creates a new tensor without modifying the original, causing the masking to have no effect when the result is not assigned back to the variable. Fixes bigdata-ustc#52
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.
Summary
Fixes #52 - Change
masked_filltomasked_fill_(in-place operation) on line 273 to prevent data leakage from future time steps in the AKT attention mechanism.Problem
The non-in-place version
masked_fill()creates a new tensor without modifying the original. Since the result was not assigned back to thescoresvariable, the masking had no effect, potentially allowing the model to peek at future responses during training.Solution
Use the in-place variant
masked_fill_()which properly modifies the tensor to enforce temporal masking.Changes
EduKTM/AKT/AKTNet.py:273:scores.masked_fill→scores.masked_fill_