Given groups=1, weight of size [10, 3, 3, 3], expected input[50, 32, 32, 3] to have 3 channels, but got 32 channels instead [closed]
up vote
-6
down vote
favorite
class Net(nn.Module):
def __init__(self):
super(Net,self).__init__()
self.conv1=nn.Conv2d(3,10,kernel_size=3,padding=1)
self.conv2=nn.Conv2d(10,20,kernel_size=3,padding=1)
self.conv3=nn.Conv2d(20,40,kernel_size=3,padding=1)
self.conv4=nn.Conv2d(40,80,kernel_size=3,padding=1)
self.pool=nn.MaxPool2d(2)
self.fc1=nn.Linear(1024,512)
self.fc2=nn.Linear(512,10)
def forward(self,x):
x=F.relu(self.conv1(x))
x=self.pool(F.relu(self.conv2(x)))
x=F.dropout()
x=F.relu(self.conv3(x))
x=self.pool(F.relu(self.conv4(x)))
x=x.view(-1,1024)
x=self.fc1
x=self.fc2
return F.Logsoftmax(x, dim=1)
net=Net()
net=net.cuda()
for epoch in range(num_epochs):
print(epoch)
X_train,Y_train=shuffle(X_train,Y_train)
for i in range(no_of_batches):
start=i*batch_size
end=(i+1)*batch_size
X_var=Variable(torch.cuda.FloatTensor(X_train[start:end]))
Y_var=Variable(torch.cuda.FloatTensor(Y_train[start:end]))
optimizer.zero_grad()
Y_pred=net(X_var)
loss=Criterion(Y_pred,Y_var)
loss.backward()
optimizer.step()
i think the problem here is that my image is 32,32,3 and i need to input image of 3,32,32 pls confirm if it is the problem and if yes pls tell me how can i solve this problem
python
closed as unclear what you're asking by usr2564301, glglgl, Thierry Lathuille, Chris, gnat Nov 10 at 19:33
Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.
add a comment |
up vote
-6
down vote
favorite
class Net(nn.Module):
def __init__(self):
super(Net,self).__init__()
self.conv1=nn.Conv2d(3,10,kernel_size=3,padding=1)
self.conv2=nn.Conv2d(10,20,kernel_size=3,padding=1)
self.conv3=nn.Conv2d(20,40,kernel_size=3,padding=1)
self.conv4=nn.Conv2d(40,80,kernel_size=3,padding=1)
self.pool=nn.MaxPool2d(2)
self.fc1=nn.Linear(1024,512)
self.fc2=nn.Linear(512,10)
def forward(self,x):
x=F.relu(self.conv1(x))
x=self.pool(F.relu(self.conv2(x)))
x=F.dropout()
x=F.relu(self.conv3(x))
x=self.pool(F.relu(self.conv4(x)))
x=x.view(-1,1024)
x=self.fc1
x=self.fc2
return F.Logsoftmax(x, dim=1)
net=Net()
net=net.cuda()
for epoch in range(num_epochs):
print(epoch)
X_train,Y_train=shuffle(X_train,Y_train)
for i in range(no_of_batches):
start=i*batch_size
end=(i+1)*batch_size
X_var=Variable(torch.cuda.FloatTensor(X_train[start:end]))
Y_var=Variable(torch.cuda.FloatTensor(Y_train[start:end]))
optimizer.zero_grad()
Y_pred=net(X_var)
loss=Criterion(Y_pred,Y_var)
loss.backward()
optimizer.step()
i think the problem here is that my image is 32,32,3 and i need to input image of 3,32,32 pls confirm if it is the problem and if yes pls tell me how can i solve this problem
python
closed as unclear what you're asking by usr2564301, glglgl, Thierry Lathuille, Chris, gnat Nov 10 at 19:33
Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.
add a comment |
up vote
-6
down vote
favorite
up vote
-6
down vote
favorite
class Net(nn.Module):
def __init__(self):
super(Net,self).__init__()
self.conv1=nn.Conv2d(3,10,kernel_size=3,padding=1)
self.conv2=nn.Conv2d(10,20,kernel_size=3,padding=1)
self.conv3=nn.Conv2d(20,40,kernel_size=3,padding=1)
self.conv4=nn.Conv2d(40,80,kernel_size=3,padding=1)
self.pool=nn.MaxPool2d(2)
self.fc1=nn.Linear(1024,512)
self.fc2=nn.Linear(512,10)
def forward(self,x):
x=F.relu(self.conv1(x))
x=self.pool(F.relu(self.conv2(x)))
x=F.dropout()
x=F.relu(self.conv3(x))
x=self.pool(F.relu(self.conv4(x)))
x=x.view(-1,1024)
x=self.fc1
x=self.fc2
return F.Logsoftmax(x, dim=1)
net=Net()
net=net.cuda()
for epoch in range(num_epochs):
print(epoch)
X_train,Y_train=shuffle(X_train,Y_train)
for i in range(no_of_batches):
start=i*batch_size
end=(i+1)*batch_size
X_var=Variable(torch.cuda.FloatTensor(X_train[start:end]))
Y_var=Variable(torch.cuda.FloatTensor(Y_train[start:end]))
optimizer.zero_grad()
Y_pred=net(X_var)
loss=Criterion(Y_pred,Y_var)
loss.backward()
optimizer.step()
i think the problem here is that my image is 32,32,3 and i need to input image of 3,32,32 pls confirm if it is the problem and if yes pls tell me how can i solve this problem
python
class Net(nn.Module):
def __init__(self):
super(Net,self).__init__()
self.conv1=nn.Conv2d(3,10,kernel_size=3,padding=1)
self.conv2=nn.Conv2d(10,20,kernel_size=3,padding=1)
self.conv3=nn.Conv2d(20,40,kernel_size=3,padding=1)
self.conv4=nn.Conv2d(40,80,kernel_size=3,padding=1)
self.pool=nn.MaxPool2d(2)
self.fc1=nn.Linear(1024,512)
self.fc2=nn.Linear(512,10)
def forward(self,x):
x=F.relu(self.conv1(x))
x=self.pool(F.relu(self.conv2(x)))
x=F.dropout()
x=F.relu(self.conv3(x))
x=self.pool(F.relu(self.conv4(x)))
x=x.view(-1,1024)
x=self.fc1
x=self.fc2
return F.Logsoftmax(x, dim=1)
net=Net()
net=net.cuda()
for epoch in range(num_epochs):
print(epoch)
X_train,Y_train=shuffle(X_train,Y_train)
for i in range(no_of_batches):
start=i*batch_size
end=(i+1)*batch_size
X_var=Variable(torch.cuda.FloatTensor(X_train[start:end]))
Y_var=Variable(torch.cuda.FloatTensor(Y_train[start:end]))
optimizer.zero_grad()
Y_pred=net(X_var)
loss=Criterion(Y_pred,Y_var)
loss.backward()
optimizer.step()
i think the problem here is that my image is 32,32,3 and i need to input image of 3,32,32 pls confirm if it is the problem and if yes pls tell me how can i solve this problem
python
python
edited Nov 10 at 21:09
Samuel Liew♦
43.7k32110143
43.7k32110143
asked Nov 10 at 18:09
yuvrajkhanna
1
1
closed as unclear what you're asking by usr2564301, glglgl, Thierry Lathuille, Chris, gnat Nov 10 at 19:33
Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.
closed as unclear what you're asking by usr2564301, glglgl, Thierry Lathuille, Chris, gnat Nov 10 at 19:33
Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.
add a comment |
add a comment |
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes