class Network(nn.Module):
def init(self,kernels1=1,extra_kernels=0):
super().init()
self.conv1 = nn.Conv2d(in_channels = 3, out_channels = 64, kernel_size = 5, padding = (1,1))#,kernels=kernels1, stride=1)
self.bn1 = nn.BatchNorm2d(64,eps=1e-05,momentum=0.15)
self.cnn1_drop = nn.Dropout2d(p=0.15)
self.conv2 = nn.Conv2d (in_channels = 64, out_channels = 128, kernel_size = 4, padding = (1,1))
self.cnn2_drop = nn.Dropout2d(p=0.15)
self.bn2 = nn.BatchNorm2d(128,eps=1e-05,momentum=0.25)
self.conv3 = nn.Conv2d(in_channels = 128, out_channels = 256, kernel_size = 3, padding = (1,1))
self.bn3 = nn.BatchNorm2d(256,eps=1e-05,momentum=0.25)
self.cnn3_drop = nn.Dropout2d(p=0.25)
self.relu=nn.ELU(alpha=6.0)
self.fc1 = nn.Linear(in_features =57600,out_features= 1000)
self.bn4 = nn.BatchNorm1d(1000)
self.cnn4_drop = nn.Dropout2d(p=0.25)
self.fc2 = nn.Linear(in_features = 1000, out_features = 100)
self.bn5 = nn.BatchNorm1d(100)
self.cnn5_drop = nn.Dropout2d(p=0.25)
self.out = nn.Linear(in_features = 100, out_features = 1)
#self.cnn6_drop = nn.Dropout2d(p=0.25)
def forward(self, t):
t = t.view(-1, t.size(-3), t.size(-2), t.size(-1))
#print('t', str(t.size()))
t = self.relu(self.bn1(self.conv1(t)))
#t=lip2d(t,kernel=3, stride=2, padding=1)
t = F.max_pool2d(t, kernel_size = 2, stride = 2)
t = self.cnn1_drop(t)
#t = self.conv1(t)
# t = F.max_pool2d(t,(t.size(-2), t.size(-1)))
# t1 = -F.max_pool2d(-t,(t.size(-2), t.size(-1)))
#t = torch.cat((t, t1),1)
#t = t.squeeze(3).squeeze(2)
#t = t.view (t.size(0),-1)
#t = t.unsqueeze(3).unsqueeze(2)
t = self.relu(self.bn2(self.conv2(t)))
t = F.max_pool2d(t, kernel_size = 2, stride = 2)
t =self.cnn2_drop(t)
t = self.relu(self.bn3(self.conv3(t)))
t = F.max_pool2d(t, kernel_size = 2, stride = 2)
t =self.cnn3_drop(t)
t = t.view (t.size(0),-1)
t = self.relu(self.bn4(self.fc1(t)))
t =self.cnn4_drop(t)
t = self.relu(self.bn5(self.fc2(t)))
t =self.cnn5_drop(t)
t = self.out(t)
#t =self.cnn6_drop(t)
return t
I am trying dis code , when i run it got the following error
RuntimeError: Given groups=1, weight of size [64, 3, 5, 5], expected input[64, 1, 128, 128] to have 3 channels, but got 1 channels instead