Ejemplo n.º 1
0
 def __init__(self, outputs, inputs):
     super(ELUN2, self).__init__()
     self.features = nn.Sequential(nn.Conv2d(inputs, 96, 6, stride=1),
                                   nn.Softplus(),
                                   nn.MaxPool2d(kernel_size=2, stride=2),
                                   nn.Conv2d(96, 512, 3, stride=1),
                                   nn.Softplus(),
                                   nn.Conv2d(512, 512, 3, stride=1),
                                   nn.Softplus(),
                                   nn.Conv2d(512, 512, 3, stride=1),
                                   nn.Softplus(),
                                   nn.MaxPool2d(kernel_size=2, stride=2),
                                   nn.Conv2d(512, 768, 3, stride=1),
                                   nn.Softplus(),
                                   nn.Conv2d(768, 768, 3, stride=1),
                                   nn.Softplus(),
                                   nn.Conv2d(768, 768, 2, stride=1),
                                   nn.Softplus(),
                                   nn.Conv2d(768, 768, 2, stride=1),
                                   nn.Softplus(),
                                   nn.Conv2d(768, 768, 1, stride=1),
                                   nn.Softplus(),
                                   nn.MaxPool2d(kernel_size=2, stride=2),
                                   nn.Conv2d(768, 1024, 3, stride=1),
                                   nn.Softplus(),
                                   nn.Conv2d(1024, 1024, 3, stride=1),
                                   nn.Softplus(),
                                   nn.Conv2d(1024, 1024, 3, stride=1),
                                   nn.Softplus(),
                                   nn.MaxPool2d(kernel_size=2, stride=2))
     self.classifier = nn.Sequential(FlattenLayer(8 * 8 * 1024),
                                     nn.Linear(8 * 8 * 1024, 4096),
                                     nn.Softplus(), nn.Linear(4096, 4096),
                                     nn.Softplus(),
                                     nn.Linear(4096, outputs))
Ejemplo n.º 2
0
    def __init__(self, outputs, inputs):
        super(BBB3Conv3FC, self).__init__()
        self.conv1 = BBBConv2d(inputs, 32, 5, stride=1, padding=2)
        self.soft1 = nn.Softplus()
        self.pool1 = nn.MaxPool2d(kernel_size=3, stride=2)

        self.conv2 = BBBConv2d(32, 64, 5, stride=1, padding=2)
        self.soft2 = nn.Softplus()
        self.pool2 = nn.MaxPool2d(kernel_size=3, stride=2)

        self.conv3 = BBBConv2d(64, 128, 5, stride=1, padding=1)
        self.soft3 = nn.Softplus()
        self.pool3 = nn.MaxPool2d(kernel_size=3, stride=2)

        self.flatten = FlattenLayer(2 * 2 * 128)
        self.fc1 = BBBLinearFactorial(2 * 2 * 128, 1000)
        self.soft5 = nn.Softplus()

        self.fc2 = BBBLinearFactorial(1000, 1000)
        self.soft6 = nn.Softplus()

        self.fc3 = BBBLinearFactorial(1000, outputs)

        layers = [
            self.conv1, self.soft1, self.pool1, self.conv2, self.soft2,
            self.pool2, self.conv3, self.soft3, self.pool3, self.flatten,
            self.fc1, self.soft5, self.fc2, self.soft6, self.fc3
        ]

        self.layers = nn.ModuleList(layers)
Ejemplo n.º 3
0
 def __init__(self, num_classes, inputs=3):
     super(AlexNet_5Conv3FC, self).__init__()
     self.features = nn.Sequential(
         nn.Conv2d(inputs, 96, kernel_size=11, stride=4),
         nn.ReLU(inplace=True),
         # nn.Dropout(p=0.5),
         nn.MaxPool2d(kernel_size=3, stride=2),
         nn.Conv2d(96, 256, kernel_size=5, stride=1, padding =2),
         nn.ReLU(inplace=True),
         nn.MaxPool2d(kernel_size=3, stride=2),
         nn.Conv2d(256, 384,  kernel_size=3, stride=1, padding =1),
         nn.ReLU(inplace=True),
         # nn.Dropout(p=0.5),
         nn.Conv2d(384, 384, kernel_size=3, stride=1, padding =1),
         nn.ReLU(inplace=True),
         nn.Conv2d(384, 256, kernel_size=3, padding=1),
         nn.ReLU(inplace=True),
         nn.MaxPool2d(kernel_size=3, stride=2),
     )
     self.classifier = nn.Sequential(
         FlattenLayer(6 * 6 * 256),
         nn.Linear(6* 6 * 256, 4096),
         nn.Dropout(p=0.5),
         nn.Linear(4096, 4096),
         nn.Dropout(p=0.5),
         nn.Linear(4096, num_classes)
     )
Ejemplo n.º 4
0
    def __init__(self, outputs, inputs):
        super(BBBAlexNet_5Conv1FC, self).__init__()
        self.conv1 = BBBConv2d(inputs, 64, kernel_size=11, stride=4, padding=5)
        self.soft1 = nn.Softplus()
        self.pool1 = nn.MaxPool2d(kernel_size=2, stride=2)

        self.conv2 = BBBConv2d(64, 192, kernel_size=5, padding=2)
        self.soft2 = nn.Softplus()
        self.pool2 = nn.MaxPool2d(kernel_size=2, stride=2)

        self.conv3 = BBBConv2d(192, 384, kernel_size=3, padding=1)
        self.soft3 = nn.Softplus()

        self.conv4 = BBBConv2d(384, 256, kernel_size=3, padding=1)
        self.soft4 = nn.Softplus()

        self.conv5 = BBBConv2d(256, 256, kernel_size=3, padding=1)
        self.soft5 = nn.Softplus()
        self.pool3 = nn.MaxPool2d(kernel_size=2, stride=2)

        self.flatten = FlattenLayer(1 * 1 * 256)
        self.fc1 = BBBLinearFactorial(1 * 1 * 256, outputs)

        layers = [
            self.conv1, self.soft1, self.pool1, self.conv2, self.soft2,
            self.pool2, self.conv3, self.soft3, self.conv4, self.soft4,
            self.conv5, self.soft5, self.pool3, self.flatten, self.fc1
        ]

        self.layers = nn.ModuleList(layers)
Ejemplo n.º 5
0
    def __init__(self, outputs, inputs,):
        super(_ClassifierD, self).__init__()
        self.outputs = outputs
        #due to the convlayer change have to assume the logvar initial value.
        self.q_logvar_init = 0.05
        self.p_logvar_init = math.log(0.05)

        self.conv1 = BBBConv2d(self.q_logvar_init, self.p_logvar_init,inputs,6, 5, stride=1)
        self.soft1 = nn.Softplus()
        self.pool1 = nn.MaxPool2d(kernel_size=2, stride=2)

        self.conv2 = BBBConv2d(self.q_logvar_init, self.p_logvar_init,6, 16, 5, stride=1)
        self.soft2 = nn.Softplus()
        self.pool2 = nn.MaxPool2d(kernel_size=2, stride=2)

        self.flatten = FlattenLayer(5 * 5 * 16)
        self.fc1 = BBBLinearFactorial(self.q_logvar_init, self.p_logvar_init,5 * 5 * 16, 120)
        self.soft3 = nn.Softplus()

        self.fc2 = BBBLinearFactorial(self.q_logvar_init, self.p_logvar_init,120, 84)
        self.soft4 = nn.Softplus()

        #self.fc3 = BBBLinearFactorial(self.q_logvar_init, self.p_logvar_init,84, outputs)

        self.fcA = BBBLinearFactorial(self.q_logvar_init, self.p_logvar_init,84, 1)
        self.fcB = BBBLinearFactorial(self.q_logvar_init, self.p_logvar_init,84, 1)
        layers = [self.conv1, self.soft1, self.pool1, self.conv2, self.soft2, self.pool2,
                  self.flatten, self.fc1, self.soft3, self.fc2, self.soft4]

        #not sure if this is right, test drive.
        self.prob = nn.Sigmoid()
        if outputs == 1:
            layers.append(self.prob)

        self.layers = nn.ModuleList(layers)
    def __init__(self, outputs, inputs):
        super(BBBLeNet, self).__init__()
        self.conv1 = BBBConv2d(inputs, 6, 5, stride=1)
        self.soft1 = nn.Softplus()
        self.pool1 = nn.MaxPool2d(kernel_size=2, stride=2)

        self.conv2 = BBBConv2d(6, 16, 5, stride=1)
        self.soft2 = nn.Softplus()
        self.pool2 = nn.MaxPool2d(kernel_size=2, stride=2)

        self.flatten = FlattenLayer(5 * 5 * 16)
        self.fc1 = BBBLinearFactorial(5 * 5 * 16, 120)
        self.soft3 = nn.Softplus()

        self.fc2 = BBBLinearFactorial(120, 84)
        self.soft4 = nn.Softplus()

        self.fc3 = BBBLinearFactorial(84, outputs)

        layers = [
            self.conv1, self.soft1, self.pool1, self.conv2, self.soft2,
            self.pool2, self.flatten, self.fc1, self.soft3, self.fc2,
            self.soft4, self.fc3
        ]

        self.layers = nn.ModuleList(layers)
Ejemplo n.º 7
0
    def __init__(self, outputs, inputs):
        super(Hybrid_5Conv3FC, self).__init__()
        self.features = nn.Sequential(
            nn.Conv2d(inputs, 96, kernel_size=11, stride=4),
            nn.ReLU(inplace=True),
            # nn.Dropout(p=0.5),
            nn.MaxPool2d(kernel_size=3, stride=2),
            nn.Conv2d(96, 256, kernel_size=5, stride=1, padding=2),
            nn.ReLU(inplace=True),
            nn.MaxPool2d(kernel_size=3, stride=2),
            nn.Conv2d(256, 384, kernel_size=3, stride=1, padding=1),
            nn.ReLU(inplace=True),
            # nn.Dropout(p=0.5),
            nn.Conv2d(384, 384, kernel_size=3, stride=1, padding=1),
            nn.ReLU(inplace=True),
            nn.Conv2d(384, 256, kernel_size=3, padding=1),
            nn.ReLU(inplace=True),
            nn.MaxPool2d(kernel_size=3, stride=2),
        )
        self.flatten = FlattenLayer(6 * 6 * 256)
        self.fc1 = BBBLinearFactorial(6 * 6 * 256, 4096)
        self.dropout1 = nn.Dropout(p=0.5)
        self.fc2 = BBBLinearFactorial(4096, 4096)
        self.dropout2 = nn.Dropout(p=0.5)
        self.fc3 = BBBLinearFactorial(4096, outputs)

        layers = [
            self.flatten, self.fc1, self.dropout1, self.fc2, self.dropout2,
            self.fc3
        ]

        self.layers = nn.ModuleList(layers)
Ejemplo n.º 8
0
 def __init__(self, outputs, inputs):
     super(CNN1, self).__init__()
     self.features = nn.Sequential(nn.Conv2d(inputs, 92, 3, stride=1),
                                   nn.Softplus(),
                                   nn.MaxPool2d(kernel_size=2, stride=1),
                                   nn.Conv2d(92, 384, 1, stride=1),
                                   nn.Softplus(),
                                   nn.Conv2d(384, 384, 2, stride=1),
                                   nn.Softplus(),
                                   nn.MaxPool2d(kernel_size=2, stride=1),
                                   nn.Conv2d(384, 640, 2, stride=1),
                                   nn.Softplus(),
                                   nn.Conv2d(640, 640, 2, stride=1),
                                   nn.Softplus(),
                                   nn.MaxPool2d(kernel_size=2, stride=1),
                                   nn.Conv2d(640, 640, 1, stride=1),
                                   nn.Softplus(),
                                   nn.Conv2d(640, 768, 2, stride=1),
                                   nn.Softplus(),
                                   nn.MaxPool2d(kernel_size=2, stride=1),
                                   nn.Conv2d(768, 768, 2, stride=1),
                                   nn.Softplus(),
                                   nn.Conv2d(768, 768, 2, stride=1),
                                   nn.Softplus(),
                                   nn.MaxPool2d(kernel_size=2, stride=1),
                                   nn.Conv2d(768, 768, 1, stride=1),
                                   nn.Softplus(),
                                   nn.Conv2d(768, 640, 2, stride=1),
                                   nn.Softplus(),
                                   nn.Conv2d(640, 384, 2, stride=1),
                                   nn.Softplus(),
                                   nn.MaxPool2d(kernel_size=2, stride=2))
     self.classifier = nn.Sequential(FlattenLayer(8 * 8 * 384),
                                     nn.Linear(8 * 8 * 384, outputs))
Ejemplo n.º 9
0
    def __init__(self, outputs, inputs):
        super(Hybrid_6Conv3FC, self).__init__()

        self.features = nn.Sequential(
            # Conv Layer block 1
            nn.Conv2d(in_channels=inputs,
                      out_channels=32,
                      kernel_size=3,
                      padding=1),
            nn.ReLU(inplace=True),
            nn.Conv2d(in_channels=32,
                      out_channels=64,
                      kernel_size=3,
                      padding=1),
            nn.ReLU(inplace=True),
            nn.MaxPool2d(kernel_size=2, stride=2),

            # Conv Layer block 2
            nn.Conv2d(in_channels=64,
                      out_channels=128,
                      kernel_size=3,
                      padding=1),
            nn.ReLU(inplace=True),
            nn.Conv2d(in_channels=128,
                      out_channels=128,
                      kernel_size=3,
                      padding=1),
            nn.ReLU(inplace=True),
            nn.MaxPool2d(kernel_size=2, stride=2),

            # Conv Layer block 3
            nn.Conv2d(in_channels=128,
                      out_channels=256,
                      kernel_size=3,
                      padding=1),
            nn.ReLU(inplace=True),
            nn.Conv2d(in_channels=256,
                      out_channels=256,
                      kernel_size=3,
                      padding=1),
            nn.ReLU(inplace=True),
            nn.MaxPool2d(kernel_size=2, stride=2),
        )

        self.flatten = FlattenLayer(4 * 4 * 256)
        self.fc1 = BBBLinearFactorial(4 * 4 * 256, 1024)
        self.soft1 = nn.Softplus()
        self.fc2 = BBBLinearFactorial(1024, 512)
        self.soft2 = nn.Softplus()
        self.dropout2 = nn.Dropout(p=0.1)
        self.fc3 = BBBLinearFactorial(512, outputs)

        layers = [
            self.flatten, self.fc1, self.soft1, self.fc2, self.soft2,
            self.dropout2, self.fc3
        ]
        self.layers = nn.ModuleList(layers)
Ejemplo n.º 10
0
 def __init__(self, outputs, inputs):
     super(ThreeFC, self).__init__()
     self.flat = FlattenLayer(784)
     self.fc1 = nn.Linear(784, 256)
     self.relu = nn.ReLU()
     self.bn1 = nn.BatchNorm1d(256)
     self.fc2 = nn.Linear(256,128)
     self.bn2 = nn.BatchNorm1d(128)
     self.fc3 = nn.Linear(128, outputs)
    def __init__(self, outputs, inputs):
        super(BBBAlexNet, self).__init__()
        # self.conv1 = BBBConv2d(inputs, 64, kernel_size=11, stride=4, padding=5)
        # self.soft1 = nn.Softplus()
        # self.pool1 = nn.MaxPool2d(kernel_size=2, stride=2)
        #
        # self.conv2 = BBBConv2d(64, 192, kernel_size=5, padding=2)
        # self.soft2 = nn.Softplus()
        # self.pool2 = nn.MaxPool2d(kernel_size=2, stride=2)
        #
        # self.conv3 = BBBConv2d(192, 384, kernel_size=3, padding=1)
        # self.soft3 = nn.Softplus()
        #
        # self.conv4 = BBBConv2d(384, 256, kernel_size=3, padding=1)
        # self.soft4 = nn.Softplus()
        #
        # self.conv5 = BBBConv2d(256, 128, kernel_size=3, padding=1)
        # self.soft5 = nn.Softplus()
        # self.pool3 = nn.MaxPool2d(kernel_size=2, stride=2)
        #
        # self.flatten = FlattenLayer(1 * 1 * 128)
        # self.fc1 = BBBLinearFactorial(1* 1 * 128, outputs)

        self.conv1 = BBBConv2d(inputs, 96, kernel_size=11, stride=4)
        self.soft1 = nn.Softplus()
        self.pool1 = nn.MaxPool2d(kernel_size=3, stride=2)

        self.conv2 = BBBConv2d(96, 256, kernel_size=5, stride=1, padding=2)
        self.soft2 = nn.Softplus()
        self.pool2 = nn.MaxPool2d(kernel_size=3, stride=2)

        self.conv3 = BBBConv2d(256, 384, kernel_size=3, stride=1, padding=1)
        self.soft3 = nn.Softplus()

        self.conv4 = BBBConv2d(384, 384, kernel_size=3, stride=1, padding=1)
        self.soft4 = nn.Softplus()

        self.conv5 = BBBConv2d(384, 256, kernel_size=3, stride=1, padding=1)
        self.soft5 = nn.Softplus()
        self.pool3 = nn.MaxPool2d(kernel_size=3, stride=2)

        self.flatten = FlattenLayer(6 * 6 * 256)
        self.fc1 = BBBLinearFactorial(6 * 6 * 256, 4096)
        self.dropout1 = nn.Dropout(p=0.5)
        self.fc2 = BBBLinearFactorial(4096, 4096)
        self.dropout2 = nn.Dropout(p=0.5)
        self.fc3 = BBBLinearFactorial(4096, outputs)

        layers = [
            self.conv1, self.soft1, self.pool1, self.conv2, self.soft2,
            self.pool2, self.conv3, self.soft3, self.conv4, self.soft4,
            self.conv5, self.soft5, self.pool3, self.flatten, self.fc1,
            self.dropout1, self.fc2, self.dropout2, self.fc3
        ]

        self.layers = nn.ModuleList(layers)
Ejemplo n.º 12
0
    def __init__(self, outputs, inputs):
        super(BBBELUN2, self).__init__()
        self.conv1 = BBBConv2d(inputs, 96, 6, stride=1)
        self.soft1 = nn.Softplus()
        self.pool1 = nn.MaxPool2d(kernel_size=2, stride=2)

        self.conv2 = BBBConv2d(96, 512, 3, stride=1)
        self.soft2 = nn.Softplus()
        self.conv3 = BBBConv2d(512, 512, 3, stride=1)
        self.soft3 = nn.Softplus()
        self.conv4 = BBBConv2d(512, 512, 3, stride=1)
        self.soft4 = nn.Softplus()
        self.pool2 = nn.MaxPool2d(kernel_size=2, stride=2)

        self.conv5 = BBBConv2d(512, 768, 3, stride=1)
        self.soft5 = nn.Softplus()
        self.conv6 = BBBConv2d(768, 768, 3, stride=1)
        self.soft6 = nn.Softplus()
        self.conv7 = BBBConv2d(768, 768, 2, stride=1)
        self.soft7 = nn.Softplus()
        self.conv8 = BBBConv2d(768, 768, 2, stride=1)
        self.soft8 = nn.Softplus()
        self.conv9 = BBBConv2d(768, 768, 1, stride=1)
        self.soft9 = nn.Softplus()
        self.pool3 = nn.MaxPool2d(kernel_size=2, stride=2)

        self.conv10 = BBBConv2d(768, 1024, 3, stride=1)
        self.soft10 = nn.Softplus()
        self.conv11 = BBBConv2d(1024, 1024, 3, stride=1)
        self.soft11 = nn.Softplus()
        self.conv12 = BBBConv2d(1024, 1024, 3, stride=1)
        self.soft12 = nn.Softplus()
        self.pool4 = nn.MaxPool2d(kernel_size=2, stride=2)

        self.flatten = FlattenLayer(8 * 8 * 1024)
        self.fc1 = BBBLinearFactorial(8 * 8 * 1024, 4096)
        self.soft13 = nn.Softplus()

        self.fc2 = BBBLinearFactorial(4096, 4096)
        self.soft14 = nn.Softplus()

        self.fc3 = BBBLinearFactorial(4096, outputs)

        layers = [
            self.conv1, self.soft1, self.pool1, self.conv2, self.soft2,
            self.conv3, self.soft3, self.conv4, self.soft4, self.pool2,
            self.conv5, self.soft5, self.conv6, self.soft6, self.conv7,
            self.soft7, self.conv8, self.soft8, self.conv9, self.soft9,
            self.pool3, self.conv10, self.soft10, self.conv11, self.soft11,
            self.conv12, self.soft12, self.pool4, self.flatten, self.fc1,
            self.soft13, self.fc2, self.soft14, self.fc3
        ]

        self.layers = nn.ModuleList(layers)
Ejemplo n.º 13
0
    def __init__(self, outputs, inputs):
        super(BBBCNN1, self).__init__()
        self.conv1 = BBBConv2d(inputs, 92, 3, stride=1)
        self.soft1 = nn.Softplus()
        self.pool1 = nn.MaxPool2d(kernel_size=2, stride=1)

        self.conv2 = BBBConv2d(92, 384, 1, stride=1)
        self.soft2 = nn.Softplus()
        self.conv3 = BBBConv2d(384, 384, 2, stride=1)
        self.soft3 = nn.Softplus()
        self.pool2 = nn.MaxPool2d(kernel_size=2, stride=1)

        self.conv4 = BBBConv2d(384, 640, 2, stride=1)
        self.soft4 = nn.Softplus()
        self.conv5 = BBBConv2d(640, 640, 2, stride=1)
        self.soft5 = nn.Softplus()
        self.pool3 = nn.MaxPool2d(kernel_size=2, stride=1)

        self.conv6 = BBBConv2d(640, 640, 1, stride=1)
        self.soft6 = nn.Softplus()
        self.conv7 = BBBConv2d(640, 768, 2, stride=1)
        self.soft7 = nn.Softplus()
        self.pool4 = nn.MaxPool2d(kernel_size=2, stride=1)

        self.conv8 = BBBConv2d(768, 768, 2, stride=1)
        self.soft8 = nn.Softplus()
        self.conv9 = BBBConv2d(768, 768, 2, stride=1)
        self.soft9 = nn.Softplus()
        self.pool5 = nn.MaxPool2d(kernel_size=2, stride=1)

        self.conv10 = BBBConv2d(768, 768, 1, stride=1)
        self.soft10 = nn.Softplus()
        self.conv11 = BBBConv2d(768, 640, 2, stride=1)
        self.soft11 = nn.Softplus()
        self.conv12 = BBBConv2d(640, 384, 2, stride=1)
        self.soft12 = nn.Softplus()
        self.pool6 = nn.MaxPool2d(kernel_size=2, stride=2)

        self.flatten = FlattenLayer(8 * 8 * 384)
        self.fc1 = BBBLinearFactorial(8 * 8 * 384, outputs)

        layers = [
            self.conv1, self.soft1, self.pool1, self.conv2, self.soft2,
            self.conv3, self.soft3, self.pool2, self.conv4, self.soft4,
            self.conv5, self.soft5, self.pool3, self.conv6, self.soft6,
            self.conv7, self.soft7, self.pool4, self.conv8, self.soft8,
            self.conv9, self.soft9, self.pool5, self.conv10, self.soft10,
            self.conv11, self.soft11, self.conv12, self.soft12, self.pool6,
            self.flatten, self.fc1
        ]

        self.layers = nn.ModuleList(layers)
Ejemplo n.º 14
0
 def __init__(self, outputs, inputs):
     super(LeNet, self).__init__()
     self.features = nn.Sequential(
         nn.Conv2d(inputs, 6, 5, stride=1),
         nn.Softplus(),
         nn.MaxPool2d(kernel_size=2, stride=2),
         nn.Conv2d(6, 16, 5, stride=1),
         nn.Softplus(),
         nn.MaxPool2d(kernel_size=2, stride=2),
     )
     self.classifier = nn.Sequential(FlattenLayer(5 * 5 * 16),
                                     nn.Linear(5 * 5 * 16, 120),
                                     nn.Softplus(), nn.Linear(120, 84),
                                     nn.Softplus(), nn.Linear(84, outputs))
Ejemplo n.º 15
0
    def __init__(self, outputs, inputs):
        super(Hybrid_timeseries_1Conv2FC, self).__init__()

        self.features = nn.Sequential(
            nn.Conv1d(inputs, 64, kernel_size=11, stride=4, padding=5),
            nn.ReLU(inplace=True),
        )

        self.flatten = FlattenLayer(1 * 1 * 64)
        self.fc1 = BBBLinearFactorial(1 * 1 * 64, 512)
        self.fc2 = BBBLinearFactorial(512, outputs)

        layers = [self.flatten, self.fc1, self.fc2]

        self.layers = nn.ModuleList(layers)
Ejemplo n.º 16
0
 def __init__(self, outputs, inputs):
     super(ELUN1, self).__init__()
     self.features = nn.Sequential(nn.Conv2d(inputs, 384, 3, stride=1),
                                   nn.Softplus(),
                                   nn.MaxPool2d(kernel_size=2, stride=1),
                                   nn.Conv2d(384, 384, 1, stride=1),
                                   nn.Softplus(),
                                   nn.Conv2d(384, 384, 2, stride=1),
                                   nn.Softplus(),
                                   nn.Conv2d(384, 640, 2, stride=1),
                                   nn.Softplus(),
                                   nn.Conv2d(640, 640, 2, stride=1),
                                   nn.Softplus(),
                                   nn.MaxPool2d(kernel_size=2, stride=1),
                                   nn.Conv2d(640, 640, 1, stride=1),
                                   nn.Softplus(),
                                   nn.Conv2d(640, 768, 2, stride=1),
                                   nn.Softplus(),
                                   nn.Conv2d(768, 768, 2, stride=1),
                                   nn.Softplus(),
                                   nn.Conv2d(768, 768, 2, stride=1),
                                   nn.Softplus(),
                                   nn.MaxPool2d(kernel_size=2, stride=1),
                                   nn.Conv2d(768, 768, 1, stride=1),
                                   nn.Softplus(),
                                   nn.Conv2d(768, 896, 2, stride=1),
                                   nn.Softplus(),
                                   nn.Conv2d(896, 896, 2, stride=1),
                                   nn.Softplus(),
                                   nn.MaxPool2d(kernel_size=2, stride=1),
                                   nn.Conv2d(896, 896, 3, stride=1),
                                   nn.Softplus(),
                                   nn.Conv2d(896, 1024, 2, stride=1),
                                   nn.Softplus(),
                                   nn.Conv2d(1024, 1024, 2, stride=1),
                                   nn.Softplus(),
                                   nn.MaxPool2d(kernel_size=2, stride=1),
                                   nn.Conv2d(1024, 1024, 1, stride=1),
                                   nn.Softplus(),
                                   nn.Conv2d(1024, 1152, 2, stride=1),
                                   nn.Softplus(),
                                   nn.MaxPool2d(kernel_size=2, stride=2),
                                   nn.Conv2d(1152, 1152, 2, stride=1),
                                   nn.Softplus(),
                                   nn.MaxPool2d(kernel_size=2, stride=2))
     self.classifier = nn.Sequential(FlattenLayer(2 * 2 * 1152),
                                     nn.Linear(2 * 2 * 1152, outputs))
Ejemplo n.º 17
0
    def __init__(self, outputs, inputs):
        super(BBBAlexNetTimeSeries_1Conv2FC, self).__init__()

        self.conv1 = BBBConv1d(inputs, 64, kernel_size=11, stride=4, padding=5)
        self.soft1 = nn.Softplus()

        #self.conv2 = BBBConv1d(64, 192, kernel_size=5, padding=2)
        #self.soft2 = nn.Softplus()

        self.flatten = FlattenLayer(1 * 1 * 64)
        self.fc1 = BBBLinearFactorial(1 * 1 * 64, 512)
        #self.fc2 = BBBLinearFactorial(4096, 4096)
        self.fc3 = BBBLinearFactorial(512, outputs)

        layers = [self.conv1, self.soft1, self.flatten, self.fc1, self.fc3]

        self.layers = nn.ModuleList(layers)
Ejemplo n.º 18
0
 def __init__(self, outputs, inputs):
     super(F3Conv3FC, self).__init__()
     self.features = nn.Sequential(
         nn.Conv2d(inputs, 32, 5, stride=1, padding=2),
         nn.Softplus(),
         nn.MaxPool2d(kernel_size=3, stride=2),
         nn.Conv2d(32, 64, 5, stride=1, padding=2),
         nn.Softplus(),
         nn.MaxPool2d(kernel_size=3, stride=2),
         nn.Conv2d(64, 128, 5, stride=1, padding=1),
         nn.Softplus(),
         nn.MaxPool2d(kernel_size=3, stride=2),
     )
     self.classifier = nn.Sequential(FlattenLayer(2 * 2 * 128),
                                     nn.Linear(2 * 2 * 128, 1000),
                                     nn.Softplus(), nn.Linear(1000, 1000),
                                     nn.Softplus(),
                                     nn.Linear(1000, outputs))
 def __init__(self, num_classes, inputs=1):
     super(ThreeFC, self).__init__()
     self.flat = FlattenLayer(784)
     self.fc1 = nn.Linear(784, 256)
     self.relu = nn.Hardtanh()
     self.bn1 = nn.BatchNorm1d(256)
     self.fc2 = nn.Linear(256,128)
     self.bn2 = nn.BatchNorm1d(128)
     self.fc3 = nn.Linear(128, num_classes)
     self.logsoftmax = nn.LogSoftmax()
     self.levels1 = Parameter(torch.Tensor(M,))
     self.index1 = torch.Tensor(self.fc1.weight.size())
     self.index2 = torch.Tensor(self.fc2.weight.size())
     self.index3 = torch.Tensor(self.fc3.weight.size())
     self.partitions1 = Parameter(torch.Tensor(M-1,))
     self.levels2 = Parameter(torch.Tensor(M,))
     self.partitions2 = Parameter(torch.Tensor(M-1,))
     self.levels3 = Parameter(torch.Tensor(M,))
     self.partitions3 = Parameter(torch.Tensor(M-1,))
Ejemplo n.º 20
0
    def __init__(self, outputs, inputs):
        super(BBBAlexNet_6Conv3FC, self).__init__()

        self.conv1 = BBBConv2d(inputs, 32, kernel_size=3, stride=1, padding=1)
        self.norm1 = nn.BatchNorm2d(32)
        self.soft1 = nn.Softplus()
        self.conv2 = BBBConv2d(32, 64, kernel_size=3, stride=1, padding=1)
        self.soft2 = nn.Softplus()
        self.pool1 = nn.MaxPool2d(kernel_size=2, stride=2)

        self.conv3 = BBBConv2d(64, 128, kernel_size=3, stride=1, padding=1)
        self.norm2 = nn.BatchNorm2d(128)
        self.soft3 = nn.Softplus()
        self.conv4 = BBBConv2d(128, 128, kernel_size=3, stride=1, padding=1)
        self.soft4 = nn.Softplus()
        self.pool2 = nn.MaxPool2d(kernel_size=2, stride=2)
        self.dropout1 = nn.Dropout(p=0.05)

        self.conv5 = BBBConv2d(128, 256, kernel_size=3, stride=1, padding=1)
        self.norm3 = nn.BatchNorm2d(256)
        self.soft5 = nn.Softplus()
        self.conv6 = BBBConv2d(256, 256, kernel_size=3, stride=1, padding=1)
        self.soft6 = nn.Softplus()
        self.pool3 = nn.MaxPool2d(kernel_size=2, stride=2)

        self.dropout2 = nn.Dropout(p=0.1)
        self.flatten = FlattenLayer(4 * 4 * 256)
        self.fc1 = BBBLinearFactorial(4 * 4 * 256, 1024)
        self.soft7 = nn.Softplus()
        self.fc2 = BBBLinearFactorial(1024, 512)
        self.soft8 = nn.Softplus()
        self.dropout3 = nn.Dropout(p=0.1)
        self.fc3 = BBBLinearFactorial(512, outputs)

        layers = [
            self.conv1, self.soft1, self.conv2, self.soft2, self.pool1,
            self.conv3, self.soft3, self.conv4, self.soft4, self.pool2,
            self.conv5, self.soft5, self.conv6, self.soft6, self.pool3,
            self.flatten, self.fc1, self.soft7, self.fc2, self.soft8,
            self.dropout3, self.fc3
        ]

        self.layers = nn.ModuleList(layers)
Ejemplo n.º 21
0
    def __init__(self, outputs, inputs):
        super(BBB4Conv3FC, self).__init__()
        self.conv1 = BBBConv2d(inputs, 32, kernel_size=5, stride=1, padding=0)
        self.soft1 = nn.Softplus()
        self.pool1 = nn.MaxPool2d(kernel_size=3, stride=2)

        self.conv2 = BBBConv2d(32, 64, kernel_size=5, stride=1, padding=0)
        self.soft2 = nn.Softplus()
        self.pool2 = nn.MaxPool2d(kernel_size=3, stride=2)

        self.conv3 = BBBConv2d(64, 128, kernel_size=5, stride=1, padding=0)
        self.soft3 = nn.Softplus()
        self.pool3 = nn.MaxPool2d(kernel_size=3, stride=2)

        self.conv4 = BBBConv2d(128, 256, kernel_size=5, stride=1, padding=0)
        self.soft4 = nn.Softplus()
        self.pool4 = nn.MaxPool2d(kernel_size=3, stride=2)

        # self.conv5 = BBBConv2d(256, 512, kernel_size=5, stride=1, padding=0)
        # self.soft5 = nn.Softplus()
        # self.pool5 = nn.MaxPool2d(kernel_size=3, stride=2)

        self.flatten = FlattenLayer(3 * 3 * 256)
        self.fc1 = BBBLinearFactorial(3 * 3 * 256, 1000)
        self.soft6 = nn.Softplus()

        self.fc2 = BBBLinearFactorial(1000, 1000)
        self.soft7 = nn.Softplus()

        self.fc3 = BBBLinearFactorial(1000, outputs)

        layers = [
            self.conv1, self.soft1, self.pool1, self.conv2, self.soft2,
            self.pool2, self.conv3, self.soft3, self.pool3, self.conv4,
            self.soft4, self.pool4, self.flatten, self.fc1, self.soft6,
            self.fc2, self.soft7, self.fc3
        ]

        self.layers = nn.ModuleList(layers)
Ejemplo n.º 22
0
    def __init__(self, inputs, num_classes):
        super(SqueezeNet, self).__init__()
        self.num_classes = num_classes
        self.features = nn.Sequential(
            nn.Conv2d(inputs, 64, kernel_size=3, stride=2),
            nn.ReLU(inplace=True),
            nn.MaxPool2d(kernel_size=3, stride=2, ceil_mode=True),
            Fire(64, 16, 64, 64),
            Fire(128, 16, 64, 64),
            nn.MaxPool2d(kernel_size=3, stride=2, ceil_mode=True),
            Fire(128, 32, 128, 128),
            Fire(256, 32, 128, 128),
            nn.MaxPool2d(kernel_size=3, stride=2, ceil_mode=True),
            Fire(256, 48, 192, 192),
            Fire(384, 48, 192, 192),
            Fire(384, 64, 256, 256),
            Fire(512, 64, 256, 256),
        )

        self.classifier = nn.Sequential(
            nn.Dropout(p=0.5), nn.Conv2d(512, self.num_classes, kernel_size=1),
            nn.ReLU(inplace=True), FlattenLayer(13 * 13 * 100),
            nn.Linear(13 * 13 * 100, num_classes))
Ejemplo n.º 23
0
    def __init__(self, outputs, inputs):
        super(BBBSqueezeNet, self).__init__()

        self.conv1 = BBBConv2d(inputs, 64, kernel_size=3, stride=2)
        self.soft1 = nn.Softplus()
        self.pool1 = nn.MaxPool2d(kernel_size=3, stride=2, ceil_mode=True)

        # Fire module 1
        self.squeeze1 = BBBConv2d(64, 16, kernel_size=1)
        self.squeeze_activation1 = nn.Softplus()
        self.expand3x3_1 = BBBConv2d(16, 128, kernel_size=3, padding=1)
        self.expand3x3_activation1 = nn.Softplus()

        # Fire module 2
        self.squeeze2 = BBBConv2d(128, 16, kernel_size=1)
        self.squeeze_activation2 = nn.Softplus()
        self.expand3x3_2 = BBBConv2d(16, 128, kernel_size=3, padding=1)
        self.expand3x3_activation2 = nn.Softplus()

        self.pool2 = nn.MaxPool2d(kernel_size=3, stride=2, ceil_mode=True)

        # Fire module 3
        self.squeeze3 = BBBConv2d(128, 32, kernel_size=1)
        self.squeeze_activation3 = nn.Softplus()
        self.expand3x3_3 = BBBConv2d(32, 256, kernel_size=3, padding=1)
        self.expand3x3_activation3 = nn.Softplus()

        # Fire module 4
        self.squeeze4 = BBBConv2d(256, 32, kernel_size=1)
        self.squeeze_activation4 = nn.Softplus()
        self.expand3x3_4 = BBBConv2d(32, 256, kernel_size=3, padding=1)
        self.expand3x3_activation4 = nn.Softplus()

        self.pool3 = nn.MaxPool2d(kernel_size=3, stride=2, ceil_mode=True)

        # Fire module 5
        self.squeeze5 = BBBConv2d(256, 48, kernel_size=1)
        self.squeeze_activation5 = nn.Softplus()
        self.expand3x3_5 = BBBConv2d(48, 384, kernel_size=3, padding=1)
        self.expand3x3_activation5 = nn.Softplus()

        # Fire module 6
        self.squeeze6 = BBBConv2d(384, 48, kernel_size=1)
        self.squeeze_activation6 = nn.Softplus()
        self.expand3x3_6 = BBBConv2d(48, 384, kernel_size=3, padding=1)
        self.expand3x3_activation6 = nn.Softplus()

        # Fire module 7
        self.squeeze7 = BBBConv2d(384, 64, kernel_size=1)
        self.squeeze_activation7 = nn.Softplus()
        self.expand3x3_7 = BBBConv2d(64, 512, kernel_size=3, padding=1)
        self.expand3x3_activation7 = nn.Softplus()

        # Fire module 8
        self.squeeze8 = BBBConv2d(512, 64, kernel_size=1)
        self.squeeze_activation8 = nn.Softplus()
        self.expand3x3_8 = BBBConv2d(64, 512, kernel_size=3, padding=1)
        self.expand3x3_activation8 = nn.Softplus()

        self.drop1 = nn.Dropout(p=0.5)
        self.conv2 = BBBConv2d(512, outputs, kernel_size=1)
        self.soft2 = nn.Softplus()
        self.flatten = FlattenLayer(13 * 13 * 100)
        self.fc1 = BBBLinearFactorial(13 * 13 * 100, outputs)

        layers = [
            self.conv1, self.soft1, self.pool1, self.squeeze1,
            self.squeeze_activation1, self.expand3x3_1,
            self.expand3x3_activation1, self.squeeze2,
            self.squeeze_activation2, self.expand3x3_2,
            self.expand3x3_activation2, self.pool2, self.squeeze3,
            self.squeeze_activation3, self.expand3x3_3,
            self.expand3x3_activation3, self.squeeze4,
            self.squeeze_activation4, self.expand3x3_4,
            self.expand3x3_activation4, self.pool3, self.squeeze5,
            self.squeeze_activation5, self.expand3x3_5,
            self.expand3x3_activation5, self.squeeze6,
            self.squeeze_activation6, self.expand3x3_6,
            self.expand3x3_activation6, self.squeeze7,
            self.squeeze_activation7, self.expand3x3_7,
            self.expand3x3_activation7, self.squeeze8,
            self.squeeze_activation8, self.expand3x3_8,
            self.expand3x3_activation8, self.drop1, self.conv2, self.soft2,
            self.flatten, self.fc1
        ]

        self.layers = nn.ModuleList(layers)
Ejemplo n.º 24
0
    def __init__(self, outputs, inputs):
        super(BBBELUN1, self).__init__()
        self.conv1 = BBBConv2d(inputs, 384, 3, stride=1)
        self.soft1 = nn.Softplus()
        self.pool1 = nn.MaxPool2d(kernel_size=2, stride=1)

        self.conv2 = BBBConv2d(384, 384, 1, stride=1)
        self.soft2 = nn.Softplus()
        self.conv3 = BBBConv2d(384, 384, 2, stride=1)
        self.soft3 = nn.Softplus()
        self.conv4 = BBBConv2d(384, 640, 2, stride=1)
        self.soft4 = nn.Softplus()
        self.conv5 = BBBConv2d(640, 640, 2, stride=1)
        self.soft5 = nn.Softplus()
        self.pool2 = nn.MaxPool2d(kernel_size=2, stride=1)

        self.conv6 = BBBConv2d(640, 640, 1, stride=1)
        self.soft6 = nn.Softplus()
        self.conv7 = BBBConv2d(640, 768, 2, stride=1)
        self.soft7 = nn.Softplus()
        self.conv8 = BBBConv2d(768, 768, 2, stride=1)
        self.soft8 = nn.Softplus()
        self.conv9 = BBBConv2d(768, 768, 2, stride=1)
        self.soft9 = nn.Softplus()
        self.pool3 = nn.MaxPool2d(kernel_size=2, stride=1)

        self.conv10 = BBBConv2d(768, 768, 1, stride=1)
        self.soft10 = nn.Softplus()
        self.conv11 = BBBConv2d(768, 896, 2, stride=1)
        self.soft11 = nn.Softplus()
        self.conv12 = BBBConv2d(896, 896, 2, stride=1)
        self.soft12 = nn.Softplus()
        self.pool4 = nn.MaxPool2d(kernel_size=2, stride=1)

        self.conv13 = BBBConv2d(896, 896, 3, stride=1)
        self.soft13 = nn.Softplus()
        self.conv14 = BBBConv2d(896, 1024, 2, stride=1)
        self.soft14 = nn.Softplus()
        self.conv15 = BBBConv2d(1024, 1024, 2, stride=1)
        self.soft15 = nn.Softplus()
        self.pool5 = nn.MaxPool2d(kernel_size=2, stride=1)

        self.conv16 = BBBConv2d(1024, 1024, 1, stride=1)
        self.soft16 = nn.Softplus()
        self.conv17 = BBBConv2d(1024, 1152, 2, stride=1)
        self.soft17 = nn.Softplus()
        self.pool6 = nn.MaxPool2d(kernel_size=2, stride=2)

        self.conv18 = BBBConv2d(1152, 1152, 2, stride=1)
        self.soft18 = nn.Softplus()
        self.pool7 = nn.MaxPool2d(kernel_size=2, stride=2)

        self.flatten = FlattenLayer(2 * 2 * 1152)
        self.fc1 = BBBLinearFactorial(2 * 2 * 1152, outputs)

        layers = [
            self.conv1, self.soft1, self.pool1, self.conv2, self.soft2,
            self.conv3, self.soft3, self.conv4, self.soft4, self.conv5,
            self.soft5, self.pool2, self.conv6, self.soft6, self.conv7,
            self.soft7, self.conv8, self.soft8, self.conv9, self.soft9,
            self.pool3, self.conv10, self.soft10, self.conv11, self.soft11,
            self.conv12, self.soft12, self.pool4, self.conv13, self.soft13,
            self.conv14, self.soft14, self.conv15, self.soft15, self.pool5,
            self.conv16, self.soft16, self.conv17, self.soft17, self.pool6,
            self.conv18, self.soft18, self.pool7, self.flatten, self.fc1
        ]

        self.layers = nn.ModuleList(layers)