Пример #1
0
    def forward(self, x1, x2, x3):
        x1 = self.convolutional(x1)  # [batch, feature, beta, alpha, gamma]
        output1 = so3_integrate(x1)  # [batch, feature]
        output1 = self.linear(output1)

        x2 = self.convolutional(x2)  # [batch, feature, beta, alpha, gamma]
        output2 = so3_integrate(x2)  # [batch, feature]
        output2 = self.linear(output2)

        x3 = self.convolutional(x3)  # [batch, feature, beta, alpha, gamma]
        output3 = so3_integrate(x3)  # [batch, feature]
        output3 = self.linear(output3)

        return output1, output2, output3
Пример #2
0
    def forward(self, x):

        x = self.seq(x)
        x = so3_integrate(x)
        x = self.out_layer(x)

        return x
 def forward(self, x):
     x = self.conv1(x)
     x = torch.nn.functional.relu(x)
     x = self.conv2(x)
     x = torch.nn.functional.relu(x)
     x = s2cnn.so3_integrate(x)
     x = self.out_layer(x)
     return x
Пример #4
0
 def forward(self, x):
     print('input', x.shape)
     x = self.convolutional(x)
     print('conv', x.shape)
     x = so3_integrate(x)
     print('so3', x.shape)
     x = self.out_layer(x)
     print('linear', x.shape)
     return x
Пример #5
0
    def forward(self, x):
        x = self.conv1(x)
        x = self.norm_layer_2d_1(x)
        x = F.relu(x)
        x = self.sdo1(x)
        x = self.conv2(x)
        x = self.norm_layer_2d_2(x)
        x = F.relu(x)
        x = self.sdo2(x)
        x = self.conv3(x)
        x = self.norm_layer_2d_3(x)
        x = F.relu(x)
        x = self.sdo3(x)
        x = self.conv4(x)
        x = self.norm_layer_2d_4(x)
        x = F.relu(x)
        x = self.sdo4(x)
        x = self.conv5(x)
        x = self.norm_layer_2d_5(x)
        x = F.relu(x)
        x = self.sdo5(x)
        x = self.conv6(x)
        x = self.norm_layer_2d_6(x)
        x = F.relu(x)

        x = so3_integrate(x)

        x = self.fc_layer(x)
        x = self.norm_1d_1(x)
        x = F.relu(x)
        x = self.do1(x)

        x = self.fc_layer_2(x)
        x = self.norm_1d_2(x)
        x = F.relu(x)
        x = self.do2(x)

        x = self.fc_layer_3(x)
        x = self.norm_1d_3(x)
        x = F.relu(x)
        x = self.do3(x)

        x = self.fc_layer_4(x)
        x = self.norm_1d_4(x)
        x = F.relu(x)
        x = self.do4(x)

        x = self.fc_layer_5(x)
        x = self.norm_1d_5(x)
        x = F.relu(x)
        x = self.do5(x)

        x = self.fc_layer_6(x)
        x = torch.sigmoid(x)
        return x
Пример #6
0
    def forward(self, x):
        """
        :param x: list( Tensor([B, 2b0, 2b0]) * num_grids )
        """

        # S2 Conv
        x = [
            self.conv0_0(x[0]),  # -> [B, f1, 2b1, 2b1, 2b1] * num_grids
            self.conv0_1(x[1]),
            self.conv0_2(x[2])
        ]
        x = [F.relu(x[0]), F.relu(x[1]), F.relu(x[2])]
        x = [self.bn0_0(x[0]), self.bn0_1(x[1]), self.bn0_2(x[2])]

        # SO3 Conv
        x = [
            self.conv1_0(x[0]),  # -> [B, f2, 2b2, 2b2, 2b2] * num_grids
            self.conv1_1(x[1]),
            self.conv1_2(x[2])
        ]
        x = [F.relu(x[i]) for i in range(len(x))]
        x = [self.bn1_0(x[0]), self.bn1_1(x[1]), self.bn1_2(x[2])]

        x = [
            self.conv2_0(x[0]),  # -> [B, f3, 2b3, 2b3, 2b3] * num_grids
            self.conv2_1(x[1]),
            self.conv2_2(x[2])
        ]
        x = [F.relu(x[i]) for i in range(len(x))]
        x = [self.bn2_0(x[0]), self.bn2_1(x[1]), self.bn2_2(x[2])]

        x = [
            self.conv3_0(x[0]),  # -> [B, f4, 2b4, 2b4, 2b4] * num_grids
            self.conv3_1(x[1]),
            self.conv3_2(x[2])
        ]
        x = [F.relu(x[i]) for i in range(len(x))]
        x = [self.bn3_0(x[0]), self.bn3_1(x[1]), self.bn3_2(x[2])]

        x = [so3_integrate(x[i])
             for i in range(len(x))]  # -> (B, f4) * num_grids

        x = [x[i].unsqueeze(0) for i in range(len(x))]
        x = torch.cat(tuple(x), dim=0)  # -> (num_grids, B, f4)

        N, B, C = x.shape

        x = x.permute(1, 2, 0)  # -> (B, f4, num_grids)
        x = torch.mul(x, torch.sigmoid(self.weights))  # -> (B, f4, num_grids)
        x = torch.sum(x, dim=-1, keepdim=False)  # -> (B, f4)

        x = self.out_layer(x)

        return x
Пример #7
0
    def forward(self, x):

        x = self.conv1(x)
        x = F.relu(x)
        x = self.conv2(x)
        x = F.relu(x)

        x = so3_integrate(x)

        x = self.out_layer(x)

        return x
Пример #8
0
    def forward(self, x):  # pylint: disable=W0221
        x = self.sequential(x)  # [batch, feature, beta, alpha, gamma]
        x = so3_integrate(x)  # [batch, feature]
        if self.dropout:
            x = self.out_layer(self.dropout(x))
        else:
            x = self.out_layer(x)
        #return F.log_softmax(x, dim=1)
        """
            if x.shape[0]>1:
        x=self.bn(x)#normalization
        """

        return x
Пример #9
0
    def forward(self, x):

        x = self.norm_layer_2d_1(x)
        x = self.conv1(x)
        x = F.relu(x)
        x = self.conv2(x)
        x = F.relu(x)
        x = self.conv3(x)
        x = F.relu(x)
        if (self.if_so3_4):
            x = self.conv4(x)
            x = F.relu(x)
            if (self.if_so3_5):
                x = self.conv5(x)
                x = F.relu(x)

        x = so3_integrate(x)
        #print(x.shape)
        x = self.fc_layer(x)
        x = self.norm_1d_1(x)
        x = F.relu(x)
        x = self.do1(x)

        x = self.fc_layer_2(x)
        x = self.norm_1d_2(x)
        x = F.relu(x)
        x = self.do2(x)

        x = self.fc_layer_3(x)
        x = self.norm_1d_3(x)
        x = F.relu(x)
        x = self.do3(x)

        if (self.if_fc_4):
            x = self.fc_layer_4(x)
            x = self.norm_1d_4(x)
            x = F.relu(x)
            x = self.do4(x)
            if (self.if_fc_5):
                x = self.fc_layer_5(x)
                x = self.norm_1d_5(x)
                x = F.relu(x)
                x = self.do5(x)

        x = self.fc_layer_6(x)
        x = self.norm_1d_6(x)
        x = F.sigmoid(x)

        return x
Пример #10
0
 def forward(self, x):
     conv1 = self.conv1(x)
     relu1 = F.relu(conv1)
     conv2 = self.conv2(relu1)
     relu2 = F.relu(conv2)  ###
     in_data = so3_integrate(
         relu2)  # -> (B * 512, 40), get rid of the (2b, 2b, 2b)
     in_reshape = in_data.reshape(self.batch_size, self.num_points,
                                  self.f2)  # (B, 512, L)
     in_reshape = in_reshape.transpose_(2, 1)  # -> (B, L, 512)
     pool3 = self.maxPool(in_reshape)  # -> (B, L)
     pool3 = pool3.squeeze()  # -> (B, L)
     # conv3 = self.conv3(in_reshape)  # (B, 1, L) -> (B, 10, L'), L' = num_points * f2 - kernel_size + 1
     # relu3 = F.relu(conv3)
     # bn3 = self.bn3(relu3)
     # bn3_reshape = bn3.reshape((self.batch_size, -1))  # (B, 10 * L')
     # output = self.out_layer(bn3_reshape)
     output = self.out_layer(pool3)
     # x = so3_integrate(x)
     # x = self.out_layer(x)
     # return x
     return output
Пример #11
0
 def forward(self, x):
     x = self.convolutional(x)
     x = so3_integrate(x)
     x = self.linear(x)
     return x
Пример #12
0
    def forward(self, data):
        """
        :param x: list( list( Tensor([B, 2b, 2b]) * num_grids ) * num_centers)
        """

        features = []
        shells = list([list(), list(), list()])
        for x in data:
            # S2 Conv
            x = [
                self.conv0_0(x[0]),  # -> [B, f1, 2b1, 2b1, 2b1] * num_grids
                self.conv0_1(x[1]),
                self.conv0_2(x[2])
            ]
            x = [F.relu(x[0]), F.relu(x[1]), F.relu(x[2])]
            x = [self.bn0_0(x[0]), self.bn0_1(x[1]), self.bn0_2(x[2])]

            # SO3 Conv
            x = [
                self.conv1_0(x[0]),  # -> [B, f2, 2b2, 2b2, 2b2] * num_grids
                self.conv1_1(x[1]),
                self.conv1_2(x[2])
            ]
            x = [F.relu(x[i]) for i in range(len(x))]
            x = [self.bn1_0(x[0]), self.bn1_1(x[1]), self.bn1_2(x[2])]

            x = [
                self.conv2_0(x[0]),  # -> [B, f3, 2b3, 2b3, 2b3] * num_grids
                self.conv2_1(x[1]),
                self.conv2_2(x[2])
            ]
            x = [F.relu(x[i]) for i in range(len(x))]
            x = [self.bn2_0(x[0]), self.bn2_1(x[1]), self.bn2_2(x[2])]

            x = [
                self.conv3_0(x[0]),  # -> [B, f4, 2b4, 2b4, 2b4] * num_grids
                self.conv3_1(x[1]),
                self.conv3_2(x[2])
            ]
            x = [F.relu(x[i]) for i in range(len(x))]
            x = [self.bn3_0(x[0]), self.bn3_1(x[1]), self.bn3_2(x[2])]

            x = [
                self.conv4_0(x[0]),  # -> [B, f5, 2b5, 2b5, 2b5] * num_grids
                self.conv4_1(x[1]),
                self.conv4_2(x[2])
            ]
            x = [F.relu(x[i]) for i in range(len(x))]
            x = [self.bn4_0(x[0]), self.bn4_1(x[1]), self.bn4_2(x[2])]

            x = [so3_integrate(x[i])
                 for i in range(len(x))]  # -> (B, f5) * num_grids

            x = [x[i].unsqueeze(0) for i in range(len(x))]
            x = torch.cat(tuple(x), dim=0)  # -> (num_grids, B, f5)

            features.append(x)

        x = torch.stack(features, dim=1)  # -> [num_grids, num_centers, B, f5]
        x = x.permute(2, 3, 0, 1)  # -> [B, f5, num_grids, num_centers]
        x, _ = torch.max(x, dim=-1)  # -> [B, f5, num_grids]

        x = torch.mul(x, torch.sigmoid(self.weights))  # -> (B, f5, num_grids)
        x = torch.sum(x, dim=-1, keepdim=False)  # -> (B, f5)
        x = self.out_layer(x)

        return x
Пример #13
0
    def forward(self, x):  # pylint: disable=W0221
        x = self.sequential(x)  # [batch, feature, beta, alpha, gamma]
        x = so3_integrate(x)  # [batch, feature]

        return x
Пример #14
0
    def forward(self, x):

        # Convolutional part
        # Input: PMT hitmap (theta, phi)
        # Output: feature map (alpha, beta, gamma)
        x = self.conv1(x)
        x = self.norm_layer_2d_1(x)
        x = F.relu(x)
        x = self.sdo1(x)
        x = self.conv2(x)
        x = self.norm_layer_2d_2(x)
        x = F.relu(x)
        x = self.sdo2(x)
        x = self.conv3(x)
        x = self.norm_layer_2d_3(x)
        x = F.relu(x)
        x = self.sdo3(x)
        x = self.conv4(x)
        x = self.norm_layer_2d_4(x)
        x = F.relu(x)
        x = self.sdo4(x)
        x = self.conv5(x)
        x = self.norm_layer_2d_5(x)
        x = F.relu(x)
        x = self.sdo5(x)
        x = self.conv6(x)
        x = self.norm_layer_2d_6(x)
        x = F.relu(x)

        # Integrate along euler angle space
        x = so3_integrate(x)

        # Fully connected part
        x = self.fc_layer(x)
        x = self.norm_1d_1(x)
        x = F.relu(x)
        x = self.do1(x)

        x = self.fc_layer_2(x)
        x = self.norm_1d_2(x)
        x = F.relu(x)
        x = self.do2(x)

        x = self.fc_layer_3(x)
        x = self.norm_1d_3(x)
        x = F.relu(x)
        x = self.do3(x)

        x = self.fc_layer_4(x)
        x = self.norm_1d_4(x)
        x = F.relu(x)
        x = self.do4(x)

        x = self.fc_layer_5(x)
        x = self.norm_1d_5(x)
        x = F.relu(x)
        x = self.do5(x)

        x = self.fc_layer_6(x)
        x = torch.sigmoid(x)
        return x
Пример #15
0
    def forward(self, x):  # pylint: disable=W0221
        x = self.sequential(x)  # [batch, feature, beta, alpha, gamma]
        x = so3_integrate(x)  # [batch, feature]

        x = self.out_layer(x)
        return F.log_softmax(x, dim=1)