Ejemplo n.º 1
0
    def __init__(self,
                 dim=3,
                 z_dim=128,
                 c_dim=128,
                 hidden_size=256,
                 leaky=False,
                 legacy=False,
                 n_classes=1,
                 instance_loss=False):
        super().__init__()
        #print('using sigmoid')
        self.z_dim = z_dim
        if not z_dim == 0:
            self.fc_z = nn.Linear(z_dim, hidden_size)

        self.fc_p = nn.Conv1d(dim, hidden_size, 1)
        self.block0 = CResnetBlockConv1d(c_dim, hidden_size, legacy=legacy)
        self.block1 = CResnetBlockConv1d(c_dim, hidden_size, legacy=legacy)
        self.block2 = CResnetBlockConv1d(c_dim, hidden_size, legacy=legacy)
        self.block3 = CResnetBlockConv1d(c_dim, hidden_size, legacy=legacy)
        self.block4 = CResnetBlockConv1d(c_dim, hidden_size, legacy=legacy)

        if not legacy:
            self.bn = CBatchNorm1d(c_dim, hidden_size)
        else:
            self.bn = CBatchNorm1d_legacy(c_dim, hidden_size)

        self.instance_loss = instance_loss

        self.fc_out = nn.Conv1d(hidden_size, n_classes, 1)
        self.fc_vote = None

        if self.instance_loss:
            self.fc_vote = nn.Conv1d(hidden_size, 3, 1)

        if not leaky:
            self.actvn = F.relu
        else:
            self.actvn = lambda x: F.leaky_relu(x, 0.2)
Ejemplo n.º 2
0
    def __init__(self,
                 dim=3,
                 z_dim=128,
                 c_dim=128,
                 hidden_size=256,
                 leaky=False,
                 legacy=False):
        super().__init__()
        self.z_dim = z_dim
        if not z_dim == 0:
            self.fc_z = nn.Linear(z_dim, hidden_size)

        self.fc_p = nn.Conv1d(dim, hidden_size, 1)
        # self.block0 = CResnetBlockConv1d(c_dim, hidden_size, legacy=legacy)
        # self.block1 = CResnetBlockConv1d(c_dim, hidden_size, legacy=legacy)
        # self.block2 = CResnetBlockConv1d(c_dim, hidden_size, legacy=legacy)
        # self.block3 = CResnetBlockConv1d(c_dim, hidden_size, legacy=legacy)
        # self.block4 = CResnetBlockConv1d(c_dim, hidden_size, legacy=legacy)
        self.block0_1 = CResnetBlockConv1d(256, hidden_size, legacy=legacy)
        self.block0_2 = CResnetBlockConv1d(256, hidden_size, legacy=legacy)
        self.block0_3 = CResnetBlockConv1d(256, hidden_size, legacy=legacy)
        self.block0_4 = CResnetBlockConv1d(256, hidden_size, legacy=legacy)
        self.block1 = CResnetBlockConv1d(67, hidden_size, legacy=legacy)
        self.block2 = CResnetBlockConv1d(131, hidden_size, legacy=legacy)
        self.block3 = CResnetBlockConv1d(259, hidden_size, legacy=legacy)
        self.block4 = CResnetBlockConv1d(515, hidden_size, legacy=legacy)

        if not legacy:
            self.bn = CBatchNorm1d(c_dim, hidden_size)
        else:
            self.bn = CBatchNorm1d_legacy(c_dim, hidden_size)

        self.fc_out = nn.Conv1d(hidden_size, 1, 1)

        if not leaky:
            self.actvn = F.relu
        else:
            self.actvn = lambda x: F.leaky_relu(x, 0.2)