Time-Series-Library
Time-Series-Library copied to clipboard
fix: prevent in-place operations in TimesNet model to avoid potential side effects
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
- In-place operators (
/=,+=, etc.) modify tensors directly, which can lead to unexpected side effects - Using non-in-place operations creates new objects, making the code behavior more predictable
- 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.