Hi, I am trying to edit the input and output channel of Mobilenet_v3_small. I have created a class for this (avoid the encoder part). The change is based on the mobilenet source code.
input_net = 3 (RGB image)
output_net = 2 (2 classes)
last_channel = 1024 (Default in Mobilenet_v3_small)
class mi_Net(nn.Module):
def __init__(self):
super(mi_Net, self).__init__()
self.model = models.mobilenet_v3_small(pretrained=True)
for param in self.model.parameters():
param.requires_grad = False
#Change input and output Mobilenet
self.model.classifier[0] = nn.Linear(input_net, last_channel)
self.model.classifier[3] = nn.Linear(last_channel, output_net)
#Encoder
self.encoder = nn.Sequential(
nn.Linear(input_encoder, 128),
nn.ReLU(),
nn.Linear(128, output_encoder),
)
self.out = nn.Linear(4, 2)
def forward(self, x, y):
#Mobilenet
x = self.model(x)
#Encoder
y = self.encoder(y)
z = torch.cat(x, y)
z = self.out(z)
return z
But when I compile I get this:
mat1 and mat2 shapes cannot be multiplied (4x576 and 3x1024)
I changed input_net = 576 (I am not sure about this)
And now the error is:
mat1 and mat2 shapes cannot be multiplied (68x3 and 17x128)
I would like to solve the first error without change input_net, but I dont know how.
Thank you!!!