https://fsjz2020.github.io/2023/05/10/%E6%B7%B1%E5%BA%A6%E5%AD%A6%E4%B9%A0%E7%AC%94%E8%AE%B0/#more
数据操作原地操作使用x[:]=x+y或x+=y来进行原地操作。 1234567x=torch.randn((3,4))y=torch.arange(12).reshape((3,4))before=id(x)x[:]=x+yid(x)==before-------------------------------True
https://fsjz2020.github.io/2023/05/10/%E6%B7%B1%E5%BA%A6%E5%AD%A6%E4%B9%A0%E7%AC%94%E8%AE%B0/#more
数据操作原地操作使用x[:]=x+y或x+=y来进行原地操作。 1234567x=torch.randn((3,4))y=torch.arange(12).reshape((3,4))before=id(x)x[:]=x+yid(x)==before-------------------------------True