Volatile mechanism in 0.4.0

Hello everyone,

I just updated to 0.4.0 recently (specifically, 0.4.0a0+816d5d8). And I found out that the volatile flag in Variable class was no longer effective. And I also found relative pull request in Github but couldn’t understand what the developer trying to do(is there still a similar mechanism to do the volatile thing) and it also seems that the related docs are not updated yet.

Anyone can give a brief explanation of this? Thanks

You do your calculation in a no_grad block.

with torch.no_grad():
   ...

The opposite (e.g. you are inside a torch.no_grad block and need gradients is with torch.enable_grad(): ....

Best regards

Thomas

2 Likes