The code and weights are pretty standard. Just a regular network on jupyter notebook
I wrote this model that converts an image into a vector, on colab
class ConvEncoder(nn.Module):
def __init__(self):
super().__init__()
self.conv1 = nn.Conv2d(3, 16, (3, 3), padding=(1, 1))
self.bn1 = nn.BatchNorm2d(16)
self.relu1 = nn.ReLU()
self.maxpool1 = nn.MaxPool2d((2, 2))
self.conv2 = nn.Conv2d(16, 32, (3, 3), padding=(1, 1))
self.bn2 = nn.BatchNorm2d(32)
self.relu2 = nn.ReLU()
self.maxpool2 = nn.MaxPool2d((2, 2))
self.conv3 = nn.Conv2d(32, 64, (3, 3), padding=(1, 1))
self.bn3 = nn.BatchNorm2d(64)
self.relu3 = nn.ReLU()
self.maxpool3 = nn.MaxPool2d((2, 2))
def forward(self, x):
x = self.conv1(x)
x = self.bn1(x)
x = self.relu1(x)
x = self.maxpool1(x)
x = self.conv2(x)
x = self.bn2(x)
x = self.relu2(x)
x = self.maxpool2(x)
x = self.conv3(x)
x = self.bn3(x)
x = self.relu3(x)
x = self.maxpool3(x)
return x
Then I did
model = ConvEncoder()
torch.save(model, 'enc.pth')
But when I download that to my local system, and run
model = torch.load('enc.pth')
I get an error saying Model not found. However if save and load it in the same place, like a colab notebook,it does work. So I’m trying to figure out what is breaking here.