def __init__(self, f_in, ratio, nratio, srange=1, nb_classes=10): super().__init__() ''' Scale equivariant arch, based on architecture in Kanazawa's paper https://arxiv.org/abs/1412.5104 selecting srange = 1 is equivalent to the paper ''' self.f_in = f_in self.ratio = ratio self.nratio = nratio self.srange = srange self.nb_classes = nb_classes self.conv1 = ScaleConvolution(self.f_in, 69, 3, self.ratio, self.nratio, srange=0, boundary_condition="dirichlet", stride=2) self.conv2 = ScaleConvolution(69, 122, 3, self.ratio, self.nratio, srange=self.srange, boundary_condition="dirichlet") self.pool = ScalePool(self.ratio) self.fc1 = nn.Linear(122, 288, bias=True) self.fc2 = nn.Linear(288, self.nb_classes, bias=True)
def __init__(self, f_in, ratio, nratio, nb_classes=10): super().__init__() ''' Basic scale equivariant architecture, replicating StdNet ''' self.f_in = f_in self.ratio = ratio self.nratio = nratio self.nb_classes = nb_classes self.conv1 = ScaleConvolution(self.f_in, 12, 7, self.ratio, self.nratio, srange=0, boundary_condition="dirichlet", stride=2) self.conv2 = ScaleConvolution(12, 21, 5, self.ratio, self.nratio, srange=1, boundary_condition="dirichlet") self.pool = ScalePool(self.ratio) self.fc1 = nn.Linear(21, 150, bias=True) self.fc2 = nn.Linear(150, self.nb_classes, bias=True)
def __init__(self, ratio, nratio): super().__init__() self.ratio = ratio self.nratio = nratio self.conv1 = ScaleConvolution(7, 3, 12, self.ratio, self.nratio, srange=0, boundary_condition="dirichlet", stride=2) self.conv2 = ScaleConvolution(5, 12, 21, self.ratio, self.nratio, srange=1, boundary_condition="dirichlet") self.pool = ScalePool(self.ratio) self.fc1 = nn.Linear(21, 150, bias=True) self.fc2 = nn.Linear(150, 10, bias=True)
def __init__(self, f_in=1, size=5, ratio=2**(2 / 3), nratio=3, srange=2, padding=0, nb_classes=10): super().__init__() ''' Scale equivariant arch with 3 convolutional layers ''' self.f_in = f_in self.size = size self.ratio = ratio self.nratio = nratio self.srange = srange self.padding = padding self.nb_classes = nb_classes self.conv1 = ScaleConvolution(self.f_in, 96, self.size, self.ratio, self.nratio, srange=0, boundary_condition="dirichlet", padding=self.padding, stride=2) self.conv2 = ScaleConvolution(96, 96, self.size, self.ratio, self.nratio, srange=self.srange, boundary_condition="dirichlet", padding=self.padding) self.conv3 = ScaleConvolution(96, 192, self.size, self.ratio, self.nratio, srange=self.srange, boundary_condition="dirichlet", padding=self.padding) self.pool = ScalePool(self.ratio) self.fc1 = nn.Linear(192, 150, bias=True) self.fc2 = nn.Linear(150, self.nb_classes, bias=True)
def __init__(self, f_in, ratio, nratio, nb_classes=10): super().__init__() ''' Smaller version of the squale equivariant All CNN ''' self.f_in = f_in self.ratio = ratio self.nratio = nratio self.nb_classes = nb_classes self.conv1 = ScaleConvolution(self.f_in, 96, 3, ratio=self.ratio, nratio=self.nratio, srange=0, boundary_condition="dirichlet", padding=1) self.conv2 = ScaleConvolution(96, 96, 3, self.ratio, self.nratio, srange=2, boundary_condition="dirichlet", padding=1) self.conv3 = ScaleConvolution(96, 192, 3, self.ratio, self.nratio, srange=2, boundary_condition="dirichlet", padding=1) self.conv4 = ScaleConvolution(192, 192, 3, self.ratio, self.nratio, srange=2, boundary_condition="dirichlet", padding=1) self.weight5 = nn.Parameter(torch.empty(self.nb_classes, 192)) nn.init.orthogonal_(self.weight5)
def __init__(self, f_in, ratio, nratio, nb_classes=10): super().__init__() ''' Squale equivariant All convolutional netw ''' self.f_in = f_in self.ratio = ratio self.nratio = nratio self.nb_classes = nb_classes self.conv1 = ScaleConvolution(self.f_in, 96, 3, ratio=self.ratio, nratio=self.nratio, srange=0, boundary_condition="dirichlet", padding=1) self.conv2 = ScaleConvolution(96, 96, 3, self.ratio, self.nratio, srange=2, boundary_condition="dirichlet", padding=1) self.conv3 = ScaleConvolution(96, 96, 3, self.ratio, self.nratio, srange=2, boundary_condition="dirichlet", padding=1, stride=2) self.conv4 = ScaleConvolution(96, 192, 3, self.ratio, self.nratio, srange=2, boundary_condition="dirichlet", padding=1) self.conv5 = ScaleConvolution(192, 192, 3, self.ratio, self.nratio, srange=2, boundary_condition="dirichlet", padding=1) self.conv6 = ScaleConvolution(192, 192, 3, self.ratio, self.nratio, srange=2, boundary_condition="dirichlet", padding=1, stride=2) self.conv7 = ScaleConvolution(192, 192, 3, self.ratio, self.nratio, srange=2, boundary_condition="dirichlet", padding=1) self.weight8 = nn.Parameter(torch.empty(192, 192)) nn.init.orthogonal_(self.weight8) self.weight9 = nn.Parameter(torch.empty(self.nb_classes, 192)) nn.init.orthogonal_(self.weight9)
def __init__(self, f_in=1, size=5, ratio=2**(2 / 3), nratio=3, srange=2, padding=0, nb_classes=10, factor=1): super().__init__() ''' Scale equivariant arch with 3 convolutional layers ''' self.f_in = f_in self.size = size self.ratio = ratio self.nratio = nratio self.srange = srange self.padding = padding self.nb_classes = nb_classes self.conv1 = ScaleConvolution(self.f_in, int(factor * 12), self.size, self.ratio, self.nratio, srange=0, boundary_condition="dirichlet", padding=self.padding, stride=2) self.conv2 = ScaleConvolution(int(factor * 12), int(factor * 21), self.size, self.ratio, self.nratio, srange=self.srange, boundary_condition="dirichlet", padding=self.padding) self.conv3 = ScaleConvolution(int(factor * 21), int(factor * 36), self.size, self.ratio, self.nratio, srange=self.srange, boundary_condition="dirichlet", padding=self.padding) self.conv4 = ScaleConvolution(int(factor * 36), int(factor * 36), self.size, self.ratio, self.nratio, srange=self.srange, boundary_condition="dirichlet", padding=self.padding) self.conv5 = ScaleConvolution(int(factor * 36), int(factor * 64), self.size, self.ratio, self.nratio, srange=self.srange, boundary_condition="dirichlet", padding=self.padding) self.conv6 = ScaleConvolution(int(factor * 64), int(factor * 64), self.size, self.ratio, self.nratio, srange=self.srange, boundary_condition="dirichlet", padding=self.padding) self.pool = ScalePool(self.ratio) self.fc = nn.Linear(int(factor * 64), self.nb_classes, bias=True)