Explicitly iniatlising a value of a tensor in c++

Is this really the recommended way to initialise a tensor’s value?

torch::NoGradGuard guard;
tensor[0] = value;

No. If you need a tensor with value, use torch::full.

1 Like