Can we dump feature map Tensor to a file and use it later to load into dataloader and train

Say my forward pass is

def forward(self, x):
x1 = F.relu(F.max_pool2d(self.conv1(x), 2))
x2 = F.relu(F.max_pool2d(self.conv2(x1), 2))
x3 = x2.view(-1, 320)
x4= F.relu(self.fc1(x3))
x5 = self.fc2(x4)
return F.log_softmax(x5)

Is there a way i can save the tensor into a .pt file and use it later as an input for the layers by loading it via dataloader?

Did you try pickling?

Thanks @munkiti for the reply. I am new to PyTorch. Can you point to any documentation regarding pickling?

i dont know of .pt file. I meant using pickle python package. You should be able to find lots of tutorials online.

1 Like