Ejemplo n.º 1
0
    def __init__(self, test_case):
        super().__init__()
        self.test_case = test_case
        self.conv1 = LayerChoice(
            [nn.Conv2d(3, 6, 3, padding=1),
             nn.Conv2d(3, 6, 5, padding=2)])
        self.pool = nn.MaxPool2d(2, 2)
        self.conv2 = LayerChoice(
            [nn.Conv2d(6, 16, 3, padding=1),
             nn.Conv2d(6, 16, 5, padding=2)],
            return_mask=True)
        self.conv3 = nn.Conv2d(16, 16, 1)

        self.skipconnect = InputChoice(n_candidates=1)
        self.skipconnect2 = InputChoice(n_candidates=2, return_mask=True)
        self.bn = nn.BatchNorm2d(16)

        self.gap = nn.AdaptiveAvgPool2d(1)
        self.fc = nn.Linear(16, 10)
Ejemplo n.º 2
0
 def __init__(self):
     super(MobileNet, self).__init__()
     self.conv1 = nn.Conv2d(3, 32, 3, 1, 1, bias=False)
     self.bn1 = nn.BatchNorm2d(32)
     self.layers = _make_mobilenet_layers(32)
     self.pool = nn.AvgPool2d(2)
     self.linear = nn.Linear(1024, 10)
     self.skipconnect1 = InputChoice(n_candidates=2,
                                     n_chosen=1,
                                     key='skip1')
     self.skipconnect2 = InputChoice(n_candidates=2,
                                     n_chosen=1,
                                     key='skip2')
     self.skipconnect3 = InputChoice(n_candidates=2,
                                     n_chosen=1,
                                     key='skip3')
     self.skipconnect4 = InputChoice(n_candidates=2,
                                     n_chosen=1,
                                     key='skip4')
     self.skipconnect5 = InputChoice(n_candidates=2,
                                     n_chosen=1,
                                     key='skip5')
     self.skipconnect6 = InputChoice(n_candidates=2,
                                     n_chosen=1,
                                     key='skip6')
Ejemplo n.º 3
0
    def __init__(self):
        super(Net, self).__init__()
        self.conv1 = LayerChoice([nn.Conv2d(3, 6, 3, padding=1), nn.Conv2d(3, 6, 5, padding=2)])
        self.pool = nn.MaxPool2d(2, 2)
        self.conv2 = LayerChoice([nn.Conv2d(6, 16, 3, padding=1), nn.Conv2d(6, 16, 5, padding=2)])
        self.conv3 = nn.Conv2d(16, 16, 1)

        self.skipconnect = InputChoice(n_candidates=1)
        self.bn = nn.BatchNorm2d(16)

        self.gap = nn.AdaptiveAvgPool2d(4)
        self.fc1 = nn.Linear(16 * 4 * 4, 120)
        self.fc2 = nn.Linear(120, 84)
        self.fc3 = nn.Linear(84, 10)
Ejemplo n.º 4
0
 def __init__(self, cell_name, prev_labels, channels):
     super().__init__(cell_name)
     self.input_choice = InputChoice(choose_from=prev_labels,
                                     n_chosen=1,
                                     return_mask=True,
                                     key=cell_name + "_input")
     self.op_choice = LayerChoice([
         nn.Conv2d(channels, channels, 3, padding=1),
         nn.Conv2d(channels, channels, 5, padding=2),
         nn.MaxPool2d(3, stride=1, padding=1),
         nn.AvgPool2d(3, stride=1, padding=1),
         nn.Identity()
     ],
                                  key=cell_name + "_op")
    def __init__(self):
        super(ToxicClassifierModel, self).__init__()
        self.BiGRU = nn.GRU(300,
                            hidden_size=LSTM_UNITS,
                            bidirectional=True,
                            num_layers=1)
        self.BiRNN = LayerChoice([
            nn.RNN(input_size=2 * LSTM_UNITS,
                   hidden_size=LSTM_UNITS,
                   bidirectional=True,
                   num_layers=1),
            nn.RNN(input_size=2 * LSTM_UNITS,
                   hidden_size=LSTM_UNITS,
                   bidirectional=True,
                   num_layers=2)
        ])
        self.hidden1 = nn.Linear(DENSE_HIDDEN_UNITS, DENSE_HIDDEN_UNITS)
        self.hidden2 = nn.Linear(DENSE_HIDDEN_UNITS, DENSE_HIDDEN_UNITS)
        self.hidden3 = nn.Linear(DENSE_HIDDEN_UNITS, 6)
        self.vectors = FastText()

        self.skipconnect1 = InputChoice(n_candidates=1)
        self.skipconnect2 = InputChoice(n_candidates=1)
Ejemplo n.º 6
0
 def __init__(self, hidden_size):
     super(Net, self).__init__()
     # two options of conv1
     self.conv1 = LayerChoice([nn.Conv2d(1, 20, 5, 1),
                               nn.Conv2d(1, 20, 3, 1)],
                              key='first_conv')
     # two options of mid_conv
     self.mid_conv = LayerChoice([nn.Conv2d(20, 20, 3, 1, padding=1),
                                  nn.Conv2d(20, 20, 5, 1, padding=2)],
                                 key='mid_conv')
     self.conv2 = nn.Conv2d(20, 50, 5, 1)
     self.fc1 = nn.Linear(4*4*50, hidden_size)
     self.fc2 = nn.Linear(hidden_size, 10)
     # skip connection over mid_conv
     self.input_switch = InputChoice(n_candidates=2,
                                     n_chosen=1,
                                     key='skip')
Ejemplo n.º 7
0
 def __init__(self, kernel_size):
     super().__init__()
     self.conv = nn.Conv2d(3, 120, kernel_size, padding=kernel_size // 2)
     self.nested_mutable = InputChoice(n_candidates=10)