def __init__(self, class_number=7): super(Network_new, self).__init__() self.class_number = class_number self.extractor1 = nn.Sequential( nn.Conv2d(in_channels=3, out_channels=64, kernel_size=3, stride=1, padding=1), RegionLayer_88(in_channels=64, grid=(4, 4)), nn.ReLU(inplace=True), nn.MaxPool2d(kernel_size=2, stride=2)) self.extractor2 = nn.Sequential( nn.Conv2d(in_channels=64, out_channels=128, kernel_size=3, stride=1, padding=1), RegionLayer_88(in_channels=128, grid=(4, 4)), nn.ReLU(inplace=True), nn.MaxPool2d(kernel_size=2, stride=2)) self.extractor3 = nn.Sequential( nn.Conv2d(in_channels=128, out_channels=256, kernel_size=3, stride=1, padding=1), RegionLayer_31(in_channels=256, grid=(4, 1)), nn.ReLU(inplace=True), nn.MaxPool2d(kernel_size=2, stride=2)) self.bottleneck = nn.Sequential( nn.Conv2d(256, 128, kernel_size=1, stride=1, padding=0, bias=False), nn.BatchNorm2d(128), nn.ReLU(inplace=True), nn.Conv2d(128, 128, 3, 1, 1, bias=False), nn.BatchNorm2d(128), nn.ReLU(inplace=True), nn.Conv2d(128, 256, kernel_size=1, stride=1, padding=0, bias=False), nn.BatchNorm2d(256)) self.pool = nn.Sequential(nn.MaxPool2d(kernel_size=2, stride=2)) # self.classifier = nn.Sequential( # nn.Linear(in_features=256, out_features=1024), # nn.ReLU(inplace=True), # nn.Dropout(0.2), # # nn.Linear(in_features=1024, out_features=1024), # nn.ReLU(inplace=True), # nn.Dropout(0.2), # # nn.Linear(in_features=1024, out_features=class_number) # ) self.conv = nn.Conv2d(256, 256, 3, 2, 1) self.avgpool = nn.AvgPool2d(kernel_size=6) self.relu = nn.ReLU(inplace=True) self.classifier = nn.Sequential( nn.Linear(in_features=256, out_features=class_number))
def __init__(self, class_number=7): super(Network_new, self).__init__() self.class_number = class_number self.extractor = nn.Sequential( nn.Conv2d(in_channels=3, out_channels=32, kernel_size=3, stride=1, padding=1), RegionLayer_88(in_channels=32, grid=(4, 4)), # ReplaceRegionLayer(in_channels=32,), nn.ReLU(), nn.MaxPool2d(kernel_size=2, stride=2), nn.BatchNorm2d(num_features=32), nn.Conv2d(in_channels=32, out_channels=16, kernel_size=3, stride=1, padding=1), nn.ReLU(), nn.BatchNorm2d(num_features=16), nn.Conv2d(in_channels=16, out_channels=16, kernel_size=3, stride=1, padding=1), nn.ReLU(), nn.MaxPool2d(kernel_size=2, stride=2), nn.BatchNorm2d(num_features=16), # nn.Conv2d(in_channels=16, out_channels=16, kernel_size=5, stride=2), # nn.ReLU(), nn.Conv2d(in_channels=16, out_channels=16, kernel_size=3, stride=1, padding=1), RegionLayer_31(in_channels=16, grid=(4, 1)), nn.ReLU(), nn.MaxPool2d(kernel_size=2, stride=2), nn.BatchNorm2d(num_features=16), nn.Conv2d(in_channels=16, out_channels=16, kernel_size=3, stride=1, padding=1), nn.ReLU(), nn.BatchNorm2d(num_features=16), nn.Conv2d(in_channels=16, out_channels=16, kernel_size=3, stride=1, padding=1), nn.ReLU(), ) self.classifier = nn.Sequential( nn.Linear(in_features=16 * 6 * 6, out_features=4096), nn.ReLU(), nn.Dropout(0.5), nn.Linear(in_features=4096, out_features=2048), nn.ReLU(), nn.Dropout(0.5), nn.Linear(in_features=2048, out_features=class_number))