I am fairly new to deep learning and machine learning in general and have been trying to teach myself.
I’m interested in understanding when and how to effectively use dropout in a CNN. While researching, I’ve encountered conflicting advice regarding its placement. Some suggest using dropout after each fully-connected layer, while others recommend applying it only after every convolutional layer or even at both points. This post has an unaccepted answer which provides some brief details but I remain uncertain.
Placing it after every conv and fully connected layer seems overly aggressive. This is what I am currently doing. My CNN is trying to classify images using a custom dataset and I am struggling to get it past 50% validation accuracy so I am experiencing more with dropout:
def forward(self, x):
x = self.bn1(F.relu(self.pool(self.conv1(x))))
x = F.relu(self.conv11(x))
x = F.relu(self.conv11(x))
x = F.relu(self.conv11(x))
x = self.bn2(F.relu(self.pool(self.conv2(x))))
x = F.relu(self.conv21(x))
x = F.relu(self.conv21(x))
x = F.relu(self.conv21(x))
x = self.bn3(F.relu(self.pool(self.conv3(x))))
x = F.relu(self.conv31(x))
x = F.relu(self.conv31(x))
x = F.relu(self.conv31(x))
x = self.bn4(F.relu(self.pool(self.conv4(x))))
x = x.view(-1, 4 * 4 * 64)
x = self.dropout(x)
x = F.relu(self.fc(x))
x = self.dropout(x)
x = self.fc2(x)
return torch.log_softmax(x, dim=1)
I am wondering when exactly you would place dropout in the forward pass to ensure it's effective.
Would appreciate any insight. Thanks in advance.