Skip to content

Conversation

@AutoVision-cloud
Copy link

Summary

Fixes #52 - Change masked_fill to masked_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 the scores variable, 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_fillscores.masked_fill_

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
@AutoVision-cloud AutoVision-cloud changed the title Fix inplace masking for AKT to prevent data leakage [BUGFIX] Fix inplace masking for AKT to prevent data leakage Oct 26, 2025
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.

Fix inplace masking for AKT

1 participant