I use to do it like this:
net(im).detach().cpu().numpy() until I got to know
detach() allows two tensors have a same data which I believe means that if I change one another will be modified.
What is the correct way to store the result of a model, for example, the loss or the embeds ?
detach() uses the same underlying data, but detaches the variable from the computation graph.
To store tensors, you could simply use
If you want to save your model parameters, I would recommend to store the
Have a look at the Serialization Semantics for more information.