I’m transitioning to 0.4 and I love the new syntax!
I have a bit of problem understanding how to use with torch.set_grad_enabled(True): to initialize tensors with grad enabled:
In [31]: with torch.set_grad_enabled(True):
...: X = torch.tensor(10)
...: y = X * 10
...:
In [32]: X.requires_grad
Out[32]: False
In [33]: y.requires_grad
Out[33]: False
If you care for a bit of unsolicited advice: Note that X.reqires_grad = True will silently not do the expected while X.reqires_grad_() will tell you about your spelling. For that reason (and for saying y = x.detach().requires_grad_() and similar more compactly) I have moved to use the function exclusively.