8000 fix: prevent in-place operations in TimesNet model to avoid potential side effects by Karesis · Pull Request #709 · thuml/Time-Series-Library · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

fix: prevent in-place operations in TimesNet model to avoid potential side effects #709

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 17, 2025

Conversation

Karesis
Copy link
Contributor
@Karesis Karesis commented Apr 9, 2025

Changes

This PR addresses potential side effects caused by in-place operations in the TimesNet model.

Modifications

  • Replaced in-place operators (e.g., /=, +=) with their non-in-place counterparts (e.g., = x / y, = x + y)
  • Ensured all tensor operations create new objects instead of modifying existing ones
  • Maintained the original mathematical operations while improving code safety

Rationale

  1. In-place operators (/=, +=, etc.) modify tensors directly, which can lead to unexpected side effects
  2. Using non-in-place operations creates new objects, making the code behavior more predictable
  3. This change prevents potential issues in model training and inference

Files Changed

  • models/TimesNet.py

Additional Notes

These modifications follow defensive programming practices by avoiding in-place operations, making the code more robust and easier to debug.

@wuhaixu2016
Copy link
Member

Thanks for your contribution.

@wuhaixu2016 wuhaixu2016 merged commit 4e40c43 into thuml:main May 17, 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.

2 participants
0