Ejemplo n.º 1
0
    def __init__(self,
                 opt,
                 kernel_size=2,
                 n_blocks=1,
                 state_dim_bottleneck=64,
                 annotation_dim_bottleneck=64):
        super(ST_blocks, self).__init__()

        assert opt.L - 2 * n_blocks * (kernel_size -
                                       1) >= 1, 'L length is insufficient'

        self.kernel_size = kernel_size
        self.n_blocks = n_blocks

        # bottleneck strategy (ST_blocks have residual connection)
        self.state_dim_bottleneck = state_dim_bottleneck
        self.annotation_dim_bottleneck = annotation_dim_bottleneck
        self.state_dim = opt.state_dim
        self.annotation_dim = opt.annotation_dim
        opt.state_dim = self.state_dim_bottleneck
        opt.annotation_dim = self.annotation_dim_bottleneck

        for i in range(self.n_blocks):
            gcnn_tp = GatedCNN(opt,
                               in_channels=self.state_dim,
                               out_channels=self.state_dim_bottleneck,
                               kernel_size=self.kernel_size)
            #gcnn_ta = GatedCNN(opt, in_channels=self.annotation_dim, out_channels=self.annotation_dim_bottleneck, kernel_size=self.kernel_size)
            opt.L = opt.L - kernel_size + 1

            gcn = GCN(opt)

            gcnn_bp = GatedCNN(opt,
                               in_channels=self.state_dim_bottleneck,
                               out_channels=self.state_dim,
                               kernel_size=self.kernel_size)
            #gcnn_ba = GatedCNN(opt, in_channels=self.annotation_dim_bottleneck, out_channels=self.annotation_dim, kernel_size=self.kernel_size)
            opt.L = opt.L - kernel_size + 1

            self.add_module("gcnn_tp_{}".format(i), gcnn_tp)
            #self.add_module("gcnn_ta_{}".format(i), gcnn_ta)
            self.add_module("gcn_{}".format(i), gcn)
            self.add_module("gcnn_bp_{}".format(i), gcnn_bp)
            #self.add_module("gcnn_ba_{}".format(i), gcnn_ba)

        opt.L = opt.init_L
        opt.state_dim = self.state_dim
        opt.annotation_dim = self.annotation_dim

        self.gcnn_tps = AttrProxy(self, "gcnn_tp_")
        #self.gcnn_tas = AttrProxy(self, "gcnn_ta_")
        self.gcns = AttrProxy(self, "gcn_")
        self.gcnn_bps = AttrProxy(self, "gcnn_bp_")
Ejemplo n.º 2
0
    def __init__(self,
                 opt,
                 kernel_size=2,
                 n_blocks=1,
                 state_dim_bottleneck=64,
                 annotation_dim_bottleneck=64):
        super(STGCN, self).__init__()

        self.batchSize = opt.batchSize
        self.state_dim = opt.state_dim
        self.n_node = opt.n_node

        # ST-Block層
        self.st_blocks = ST_blocks(
            opt,
            kernel_size=kernel_size,
            n_blocks=n_blocks,
            state_dim_bottleneck=state_dim_bottleneck,
            annotation_dim_bottleneck=annotation_dim_bottleneck)
        opt.L = opt.L - 2 * n_blocks * (kernel_size - 1)

        # 出力層 GCNN (時間軸を単一ステップへマッピング)
        self.gcnn = GatedCNN(opt,
                             in_channels=self.state_dim,
                             out_channels=self.state_dim,
                             kernel_size=opt.L)
        opt.L = 1

        # 出力層 FC (回帰用)
        self.out = nn.Sequential(nn.Linear(self.state_dim, opt.output_dim), )

        opt.L = opt.init_L
        self._initialization()
Ejemplo n.º 3
0
    def __init__(self,
                 opt,
                 kernel_size=2,
                 n_blocks=1,
                 state_dim_bottleneck=64,
                 annotation_dim_bottleneck=64):
        super(STGGNN, self).__init__()

        self.batchSize = opt.batchSize
        self.state_dim = opt.state_dim
        self.n_node = opt.n_node

        # ST-Block
        self.st_blocks = ST_blocks(
            opt,
            kernel_size=kernel_size,
            n_blocks=n_blocks,
            state_dim_bottleneck=state_dim_bottleneck,
            annotation_dim_bottleneck=annotation_dim_bottleneck)
        opt.L = opt.L - 2 * n_blocks * (kernel_size - 1)

        #  GCNN ()
        self.gcnn = GatedCNN(opt,
                             in_channels=self.state_dim,
                             out_channels=self.state_dim,
                             kernel_size=opt.L)
        opt.L = 1

        #  FC ()
        self.out = nn.Sequential(nn.Linear(self.n_node, self.n_node),
                                 nn.Sigmoid())

        opt.L = opt.init_L
        self._initialization()