I am new to AI and python, I’m trying to build an architecture for inference but up till now, I couldn’t understand how to get the inputs and outputs correctly. I keep seeing the error:
RuntimeError: mat1 and mat2 shapes cannot be multiplied (1x3 and 2048x1000)
Any suggestions on how to resolve ?
class RN50(torch.nn.Module):
def __init__(self, rn50):
super(RN50, self).__init__()
self.avgpool = rn50.avgpool
self.fc = rn50.fc
def forward(self, x):
x = self.avgpool(x)
x = torch.flatten(x, 1)
x = self.fc(x)
return x
def calibration(model_path):
end_model=torch.jit.load(model_path)
for i, (images, target) in enumerate(cal_loader):
output = end_model(images)
r50end = RN50(rn50)
x = torch.rand([112, 2048, 7, 7 ], dtype=torch.float32).contiguous()
with torch.no_grad():
model = torch.jit.trace(r50end, x).eval()
model.save("rn50.pt")
calibration("rn50.pt")