class Net(nn.Module):
def __init__(self):
super(Net, self).__init__()
self.conv1 = nn.Conv2d(3, 128, 3, 1, 1)
self.relu1 = nn.ReLU()
self.pool1 = nn.MaxPool2d(2)
self.conv2 = nn.Conv2d(128, 256, 3, 1, 1)
self.relu2 = nn.ReLU()
self.pool2 = nn.MaxPool2d(2)
self.fc1 = nn.Linear(256 * 56 * 56, 20)
self.fc2 = nn.Linear(20, 1)
def forward(self, x):
x = self.conv1(x)
x = self.relu1(x)
x = self.pool1(x)
x = self.conv2(x)
x = self.relu2(x)
x = self.pool2(x)
x = x.view(x.size(0), -1)
x = self.fc1(x)
x = self.fc2(x)
return x
model = Net()
criterion = nn.CrossEntropyLoss()
learning_rate = 0.1
optimizer = torch.optim.SGD(model.parameters(), lr = learning_rate)
train_loader = torch.utils.data.DataLoader(dataset=load_dataset(), batch_size=200, shuffle=True)
validation_loader = torch.utils.data.DataLoader(dataset=load_validate(), batch_size=5000, shuffle=True)
Try to fixed follow this link but nothing changed.
https://discuss.pytorch.org/t/always-output-of-0/21784/4