def __init__(self, in_planes, planes, stride=1): super(Bottleneck, self).__init__() self.conv1 = nn.Conv2d(in_planes, planes, kernel_size=1, bias=False) self.bn1 = nn.BatchNorm2d(planes) #self.conv2 = nn.Conv2d(planes, planes, kernel_size=3, stride=stride, padding=1, bias=False) self.conv2 = deform_conv.DeformConv2D(planes, planes, kernel_size=3, padding=1) self.bn2 = nn.BatchNorm2d(planes) #self.conv3 = deform_conv.DeformConv2D(planes, self.expansion*planes, kernel_size=1, bias=False) self.conv3 = nn.Conv2d(planes, self.expansion * planes, kernel_size=1, bias=False) self.bn3 = nn.BatchNorm2d(self.expansion * planes) self.shortcut = nn.Sequential() #print("shortcut") if stride != 1 or in_planes != self.expansion * planes: #print("stride: ", stride, " in_planes: ", in_planes) self.shortcut = nn.Sequential( nn.Conv2d(in_planes, self.expansion * planes, kernel_size=1, stride=stride, bias=False), nn.BatchNorm2d(self.expansion * planes))
def __init__(self): super(MyAttenNet, self).__init__() self.base_model = nn.Sequential( nn.Conv2d(1, 64, kernel_size=4, padding=2), nn.BatchNorm2d(64), nn.PReLU(), nn.MaxPool2d(kernel_size=2), nn.Dropout2d(0.1), deform_conv.DeformConv2D(64, 128, kernel_size=4, padding=1), nn.BatchNorm2d(128), nn.PReLU(), nn.MaxPool2d(kernel_size=2), nn.Dropout2d(0.3), #deform_conv.DeformConv2D(128, 128, kernel_size=3, padding=1), ) self.atten = nn.Sequential(nn.Conv2d(128, 1, 1, 1), nn.Softplus(beta=1, threshold=20)) self.fc = nn.Sequential( nn.Linear(7 * 7 * 128, 512), nn.PReLU(), nn.Dropout(0.5), nn.Linear(512, 64), nn.PReLU(), nn.Dropout(0.5), nn.Linear(64, 10), )
def __init__(self, in_planes, planes, stride=1): super(BasicBlock, self).__init__() self.conv1 = nn.Conv2d(in_planes, planes, kernel_size=3, stride=stride, padding=1, bias=False) self.bn1 = nn.BatchNorm2d(planes) #self.conv2 = nn.Conv2d(planes, planes, kernel_size=3, stride=1, padding=1, bias=False) self.conv2 = deform_conv.DeformConv2D(planes, planes, stride=stride, kernel_size=3, bias=False) self.bn2 = nn.BatchNorm2d(planes) self.shortcut = nn.Sequential() if stride != 1 or in_planes != self.expansion * planes: self.shortcut = nn.Sequential( nn.Conv2d(in_planes, self.expansion * planes, kernel_size=1, stride=stride, bias=False), nn.BatchNorm2d(self.expansion * planes))
def __init__(self): super(DeformNet, self).__init__() self.conv1 = nn.Conv2d(3, 32, kernel_size=3, padding=1, bias = False) self.bn1 = nn.BatchNorm2d(32) self.conv2 = nn.Conv2d(32, 64, kernel_size=3, padding=1, bias = False) self.bn2 = nn.BatchNorm2d(64) self.conv3 = nn.Conv2d(64, 128, kernel_size=3, padding=1, bias = False) self.bn3 = nn.BatchNorm2d(128) self.conv4 = deform_conv.DeformConv2D(128, 128, kernel_size=3, padding=1, bias = False) self.bn4 = nn.BatchNorm2d(128) #self.classifier = nn.Linear(128, 10) self.classifier = nn.Linear(128, 10)
def __init__(self, in_planes, planes, stride=1): #print("Bottleneck2") super(Bottleneck2, self).__init__() #cannot apply deformable conv to conv1 and conv3 becasue the kernel size is 1 self.conv1 = nn.Conv2d(in_planes, planes, kernel_size=1, bias=False) self.bn1 = nn.BatchNorm2d(planes) self.offsets = nn.Conv2d(planes, 18, kernel_size=3, padding=1, stride=stride) self.conv2 = deform_conv.DeformConv2D(planes, planes, kernel_size=3, padding=1) #self.conv2 = nn.Conv2d(planes, planes, kernel_size=3, stride=stride, padding=1, bias=False) self.bn2 = nn.BatchNorm2d(planes) self.conv3 = nn.Conv2d(planes, self.expansion * planes, kernel_size=1, bias=False) self.bn3 = nn.BatchNorm2d(self.expansion * planes) self.shortcut = nn.Sequential() #print("shortcut") if stride != 1 or in_planes != self.expansion * planes: #print("stride: ", stride, " in_planes: ", in_planes) self.shortcut = nn.Sequential( nn.Conv2d(in_planes, self.expansion * planes, kernel_size=1, stride=stride, bias=False), nn.BatchNorm2d(self.expansion * planes))