Thanks for your prompt help @SimonW , can you elaborate a bit about this, i don’t quite understand what it means:
rand_result[leaf, requires_grad=True] ==> inp[intermediate result from rand_result.to()] ==> ...
I guess what you mean is in the first example, torch.rand() returns a leaf, after to(), inp is an intermediate. Seems similar to Variable(Tensor, requires_grad=True).cuda().