Hi all,I define a simple model in terminal as following.
class simple(nn.Module):
def init(self):
super(simple, self).init()
self.net = nn.Linear(28 * 28, 2)
def forward(self, x):
x = np.array(x)
x = torch.from_numpy(x)
x = Variable(x)
x = x.view(1,1,28,28)
batch_size = x.size(0)
x = x.view(batch_size, -1)
output = self.net(x.float())
return out
model = simple()
And I save it by torch.save(model,‘simple.pkl’).
Then,I open a new terminal,but I cannot load the model above by torch.load(‘simple.pkl’). However,If I use a model from torchvision.models such as VGG,It works.Why this happens?How could I load my own model?