Example #1
0
    def __init__(self,
                 embedding_dim=64,
                 h_dim=64,
                 mlp_dim=1024,
                 bottleneck_dim=1024,
                 activation='relu',
                 batch_norm=True,
                 dropout=0.0,
                 pooling_dim=2,
                 neighborhood_size=2.0,
                 pool_every=False):
        super(PoolHiddenNet, self).__init__()

        self.mlp_dim = mlp_dim
        self.h_dim = h_dim
        self.bottleneck_dim = bottleneck_dim
        self.embedding_dim = embedding_dim
        self.pooling_dim = pooling_dim
        self.neighborhood_size = neighborhood_size

        mlp_pre_dim = embedding_dim + h_dim

        mlp_pre_pool_dims = [mlp_pre_dim, self.mlp_dim * 8, bottleneck_dim]
        self.spatial_embedding = nn.Linear(pooling_dim,
                                           embedding_dim).to(device)
        self.mlp_pre_pool = make_mlp(mlp_pre_pool_dims,
                                     activation=activation,
                                     batch_norm=batch_norm,
                                     dropout=dropout)
Example #2
0
    def __init__(self,
                 h_dim=64,
                 bottleneck_dim=1024,
                 activation='relu',
                 batch_norm=True,
                 dropout=0.0,
                 neighborhood_size=2.0,
                 grid_size=8,
                 pool_dim=None):
        super(SocialPoolingAttention, self).__init__()
        self.h_dim = h_dim
        self.grid_size = grid_size
        self.neighborhood_size = neighborhood_size

        self.attention_decoder = Attention_Decoder(
            attention_dim=bottleneck_dim,
            embed_dim=4,
            decoder_dim=h_dim,
            encoder_dim=h_dim)

        mlp_pool_dims = [bottleneck_dim, bottleneck_dim]

        self.mlp_pool = make_mlp(mlp_pool_dims,
                                 activation=activation,
                                 batch_norm=batch_norm,
                                 dropout=dropout).to(device)
Example #3
0
    def __init__(self,
                 obs_len,
                 pred_len,
                 embedding_dim=64,
                 h_dim=64,
                 mlp_dim=1024,
                 num_layers=1,
                 activation='relu',
                 batch_norm=True,
                 dropout=0.0,
                 d_type='local',
                 grid_size=8,
                 neighborhood_size=2.0):
        super(TrajectoryDiscriminator, self).__init__()

        self.obs_len = obs_len
        self.pred_len = pred_len
        self.seq_len = obs_len + pred_len
        self.mlp_dim = mlp_dim
        self.h_dim = h_dim
        self.d_type = d_type

        self.encoder = Encoder(embedding_dim=embedding_dim,
                               h_dim=h_dim,
                               mlp_dim=mlp_dim,
                               num_layers=num_layers,
                               dropout=dropout)

        real_classifier_dims = [h_dim, mlp_dim, 1]
        self.real_classifier = make_mlp(real_classifier_dims,
                                        activation=activation,
                                        batch_norm=batch_norm,
                                        dropout=dropout)
Example #4
0
    def __init__(self,
                 obs_len,
                 pred_len,
                 embedding_dim=64,
                 encoder_h_dim=64,
                 decoder_h_dim=128,
                 mlp_dim=1024,
                 num_layers=1,
                 noise_dim=(0, ),
                 noise_type='gaussian',
                 noise_mix_type='ped',
                 dropout=0.0,
                 activation='relu',
                 batch_norm=True,
                 pooling=None,
                 pooling_output_dim=64,
                 decoder=None):
        super(TrajectoryGenerator, self).__init__()

        self.obs_len = obs_len
        self.pred_len = pred_len
        self.mlp_dim = mlp_dim
        self.encoder_h_dim = encoder_h_dim
        self.decoder_h_dim = decoder_h_dim
        self.embedding_dim = embedding_dim
        self.noise_dim = noise_dim
        self.num_layers = num_layers
        self.noise_type = noise_type
        self.noise_mix_type = noise_mix_type
        self.noise_first_dim = 0

        # pooling options
        self.pooling = pooling
        self.pooling_output_dim = pooling_output_dim

        self.encoder = Encoder(embedding_dim=embedding_dim,
                               h_dim=encoder_h_dim,
                               mlp_dim=mlp_dim,
                               num_layers=num_layers,
                               dropout=dropout)

        self.decoder = decoder

        if self.noise_dim[0] == 0:
            self.noise_dim = None
        else:
            self.noise_first_dim = noise_dim[0]

        mlp_input_dim = self.pooling_output_dim
        if self.mlp_decoder_needed():
            mlp_decoder_context_dims = [
                mlp_input_dim, mlp_dim, decoder_h_dim - self.noise_first_dim
            ]

            self.mlp_decoder_context = make_mlp(mlp_decoder_context_dims,
                                                activation=activation,
                                                batch_norm=batch_norm,
                                                dropout=dropout)
Example #5
0
    def __init__(
        self, obs_len, pred_len, embedding_dim=64, h_dim=64, mlp_dim=1024,
        num_layers=1, activation='relu', batch_norm=True, dropout=0.0,
        c_type='local', collision_threshold=.25, occupancy_threshold=1.0,
        down_samples=200, pooling=None, pooling_output_dim=64
    ):

        super(TrajectoryCritic, self).__init__()

        self.obs_len = obs_len
        self.pred_len = pred_len
        self.seq_len = obs_len + pred_len
        self.mlp_dim = mlp_dim
        self.h_dim = h_dim
        self.activation = activation
        self.c_type = c_type
        self.collision_threshold = collision_threshold
        self.occupancy_threshold = occupancy_threshold

        # pooling options
        self.noise_first_dim = 0
        self.pooling = pooling
        self.pooling_output_dim=pooling_output_dim

        self.encoder = Encoder(
            embedding_dim=embedding_dim,
            h_dim=h_dim,
            mlp_dim=mlp_dim,
            num_layers=num_layers,
            dropout=dropout
        )

        real_classifier_dims = [self.pooling_output_dim, mlp_dim, 1]
        self.real_classifier = make_mlp(
                real_classifier_dims,
                activation=activation,
                batch_norm=batch_norm,
                dropout=dropout)

        mlp_dims = [self.pooling_output_dim, mlp_dim, 64]
        self.mlp = make_mlp(
                mlp_dims,
                activation=activation,
                batch_norm=batch_norm,
                dropout=dropout)
Example #6
0
    def __init__(self,
                 seq_len,
                 embedding_dim=64,
                 h_dim=128,
                 mlp_dim=1024,
                 num_layers=1,
                 pool_every_timestep=True,
                 dropout=0.0,
                 activation='relu',
                 batch_norm=True,
                 pool_static_type='None',
                 pooling=None,
                 pooling_output_dim=64):
        super(Decoder, self).__init__()

        self.seq_len = seq_len
        self.mlp_dim = mlp_dim
        self.h_dim = h_dim
        self.embedding_dim = embedding_dim

        # pooling options
        if pool_static_type and pool_static_type.lower() == 'none':
            pool_static_type = None
        self.pool_static_type = pool_static_type
        self.pool_every_timestep = pool_every_timestep
        self.pooling = pooling
        self.pooling_output_dim = pooling_output_dim

        self.decoder = nn.LSTM(embedding_dim,
                               h_dim,
                               num_layers,
                               dropout=dropout)

        if pool_every_timestep:
            mlp_dims = [self.pooling_output_dim, mlp_dim, h_dim]
            self.mlp = make_mlp(mlp_dims,
                                activation=activation,
                                batch_norm=batch_norm,
                                dropout=dropout)

        self.spatial_embedding = nn.Linear(2, embedding_dim).to(device)
        self.hidden2pos = nn.Linear(h_dim, 2)
Example #7
0
    def __init__(self,
                 h_dim=64,
                 bottleneck_dim=1024,
                 activation='relu',
                 batch_norm=True,
                 dropout=0.0,
                 neighborhood_size=2.0,
                 grid_size=8,
                 pool_dim=None):
        super(SocialPooling, self).__init__()
        self.h_dim = h_dim
        self.grid_size = grid_size
        self.neighborhood_size = neighborhood_size
        if pool_dim:
            mlp_pool_dims = [grid_size * grid_size * h_dim, pool_dim]
        else:
            mlp_pool_dims = [grid_size * grid_size * h_dim, bottleneck_dim]

        self.mlp_pool = make_mlp(mlp_pool_dims,
                                 activation=activation,
                                 batch_norm=batch_norm,
                                 dropout=dropout)
Example #8
0
    def __init__(self,
                 embedding_dim=64,
                 h_dim=64,
                 mlp_dim=1024,
                 bottleneck_dim=1024,
                 activation='relu',
                 batch_norm=True,
                 dropout=0.0,
                 grid_size=8,
                 neighborhood_size=2.0,
                 pool_static_type='random',
                 down_samples=200):
        super(GridPooling, self).__init__()

        self.mlp_dim = mlp_dim
        self.h_dim = h_dim
        self.bottleneck_dim = bottleneck_dim
        self.embedding_dim = embedding_dim
        self.neighborhood_size = neighborhood_size
        self.pool_static_type = pool_static_type
        self.grid_size = grid_size
        self.encoder_dim = 1
        self.static_scene_feature_extractor = StaticFeatures(down_samples)

        self.attention_decoder = Attention_Decoder(
            attention_dim=bottleneck_dim,
            embed_dim=4,
            decoder_dim=h_dim,
            encoder_dim=1)

        mlp_pool_dims = [bottleneck_dim, bottleneck_dim]

        self.mlp_pool = make_mlp(mlp_pool_dims,
                                 activation=activation,
                                 batch_norm=batch_norm,
                                 dropout=dropout).to(device)