Hi,
I hava a basic classifier fo predict MNIST digits as below:
class LeNet_dropout(nn.Module):
def __init__(self):
super(LeNet_dropout, self).__init__()
self.conv1 = nn.Conv2d(1, 10, kernel_size=3)
self.conv2 = nn.Conv2d(10, 20, kernel_size=3)
self.fc1 = nn.Linear(2880, 128)
self.fc2 = nn.Linear(128, 10)
self.drop_layer = nn.Dropout(p=0.5)
def last_hidden_layer_output(self, x):
x = F.relu(self.conv1(x))
x = F.max_pool2d(self.drop_layer(F.relu(self.conv2(x))), 2)
x = x.view(-1, 2880)
x = self.drop_layer(F.relu(self.fc1(x)))
return x
def forward(self, x):
x = self.last_hidden_layer_output(x)
x = self.fc2(x)
return x
When I want to enable dropout, I simple pass my model to enable_dropout method as below:
def enable_dropout(model):
for m in model.modules():
if m.__class__.__name__.startswith('Dropout'):
m.train()
My question is: I want to use “DropBlock” in the second Conv layer instead of normal dropout. I am not sure if there is a built-in pytorch functionality for DropBlock operation.
Can somebody help me on this?
Best Regards…