d2l-ai / d2l-en

Interactive deep learning book with multi-framework code, math, and discussions. Adopted at 500 universities from 70 countries including Stanford, MIT, Harvard, and Cambridge.
https://D2L.ai
Other
22.45k stars 4.19k forks source link

question about ”d2l = sys.modules[__name__]“ #2589

Open lprdsb opened 4 months ago

lprdsb commented 4 months ago

I want to know why in d2l.torch there is this line of code: d2l = sys.modules[name], which causes my IDE to not correctly recognize some functions inside torch. When I try to view the source code, it doesn't jump to the correct location. However, I believe there might be another purpose for writing it this way, and I want to understand the benefits of doing so.