I am trying to save the intermediate output, the Tensor object output of a pre-trained model layer to a file, and loading it back using pickle dump/load. when I convert to a dump and loading it back, the grad_fn object in the tensor is getting removed and replaced by requires_grad.
Original:
tensor([[[[ 7.3672e-01,  3.9696e-01,  8.4902e-01,  …, -5.8079e-01,
4.0203e+00,  1.5609e+00],
…,
[         [-9.5835e-01,  5.4335e-01,  9.7559e-01,  …, -2.1748e+00,
-3.4150e+00, -8.7405e+00]]]], grad_fn=)
Converted:
tensor([[[[ 7.3672e-01,  3.9696e-01,  8.4902e-01,  …, -5.8079e-01,
4.0203e+00,  1.5609e+00],
…,
[-9.5835e-01,  5.4335e-01,  9.7559e-01,  …, -2.1748e+00,
-3.4150e+00, -8.7405e+00]]]], requires_grad=True)
Is there a way I can avoid this? or is there a way to add grad_fn to a tensor object manually. For Ex: I want to know if there a way to set MkldnnConvolutionBackward as grad_fn when i can reconstruct the tensor object matrix from data of the orginal tensor object
Thank You for any assistance