Beispiel #1
0
    def __init__(self, pool_static_type, down_samples, embedding_dim, h_dim,
                 bottleneck_dim, activation, batch_norm, dropout, mlp_dim,
                 num_cells, neighborhood_size):
        super(StaticSceneFeatureExtractorRandom, self).__init__()

        self.pool_static_type = pool_static_type
        self.down_samples = down_samples
        self.embedding_dim = embedding_dim
        self.mlp_dim = mlp_dim
        self.num_cells = num_cells
        self.neighborhood_size = neighborhood_size
        self.scene_information = {}

        if self.down_samples != -1:
            self.spatial_embedding = nn.Linear(2 * self.down_samples,
                                               embedding_dim)
        else:
            self.spatial_embedding = nn.Linear(2 * self.num_cells,
                                               embedding_dim)

        mlp_pre_pool_dims = [
            embedding_dim + h_dim, self.mlp_dim * 8, bottleneck_dim
        ]
        self.mlp_pre_pool = make_mlp(mlp_pre_pool_dims,
                                     activation=activation,
                                     batch_norm=batch_norm,
                                     dropout=dropout)
Beispiel #2
0
    def __init__(self, pool_static_type, down_samples, embedding_dim, h_dim,
                 bottleneck_dim, activation, batch_norm, dropout, mlp_dim,
                 num_cells, neighborhood_size):
        super(StaticSceneFeatureExtractorCNN, self).__init__()

        self.pool_static_type = pool_static_type
        self.down_samples = down_samples
        self.embedding_dim = embedding_dim
        self.mlp_dim = mlp_dim
        self.num_cells = num_cells
        self.neighborhood_size = neighborhood_size
        self.scene_information = {}

        if self.pool_static_type == 'random_cnn':
            self.spatial_embedding = nn.Sequential(
                nn.Conv1d(1,
                          1,
                          kernel_size=(self.down_samples // self.embedding_dim,
                                       2),
                          stride=self.down_samples // self.embedding_dim),
                nn.LeakyReLU()).to(device)

        elif self.pool_static_type == 'random_cnn_atrous':
            self.spatial_embedding = nn.Sequential(
                nn.Conv1d(1,
                          1,
                          kernel_size=(self.down_samples // self.embedding_dim,
                                       2),
                          stride=1,
                          dilation=(self.embedding_dim, 1)),
                nn.LeakyReLU()).to(device)

        else:
            print("Error in recognizing the cnn pool static type!")
            exit()

        mlp_pre_pool_dims = [
            embedding_dim + h_dim, self.mlp_dim * 8, bottleneck_dim
        ]
        self.mlp_pre_pool = make_mlp(mlp_pre_pool_dims,
                                     activation=activation,
                                     batch_norm=batch_norm,
                                     dropout=dropout)