Esempio n. 1
0
    def _build(self):

        self.layers.append(
            layers.GraphConvolution(
                input_dim=self.input_dim
                if not self.precalc else self.input_dim * 2,
                output_dim=FLAGS.hidden1,
                placeholders=self.placeholders,
                act=tf.nn.relu,
                dropout=True,
                sparse_inputs=self.sparse_inputs,  # False
                logging=self.logging,
                norm=self.norm,
                precalc=self.precalc,
                residual=self.residual))

        for _ in range(self.num_layers - 2):
            self.layers.append(
                layers.GraphConvolution(
                    input_dim=FLAGS.hidden1
                    if not self.residual else FLAGS.hidden1 * 2,
                    output_dim=FLAGS.hidden1,
                    placeholders=self.placeholders,
                    act=tf.nn.relu,
                    dropout=True,
                    sparse_inputs=False,
                    logging=self.logging,
                    norm=self.norm,
                    precalc=False,
                    residual=self.residual))

        self.layers.append(
            layers.GraphConvolution(input_dim=FLAGS.hidden1 if
                                    not self.residual else FLAGS.hidden1 * 2,
                                    output_dim=self.output_dim,
                                    placeholders=self.placeholders,
                                    act=lambda x: x,
                                    dropout=True,
                                    logging=self.logging,
                                    norm=False,
                                    precalc=False,
                                    residual=self.residual))
Esempio n. 2
0
    def __init__(self, args, adj, node_num, re_hidden, dis_hidden, vi_feature,
                 kernel_size, alphi1, alphi2, alphi3):
        super(MTGC, self).__init__()
        # Mask Temporal Graph Convolution
        self.adj = adj
        self.node_num = node_num
        self.re_hidden = re_hidden
        self.dis_hidden = dis_hidden
        self.vi_feature = vi_feature
        self.kernel_size = kernel_size

        self.alphi1 = alphi1
        self.alphi2 = alphi2
        self.alphi3 = alphi3

        # feature extraction

        self.s_conv = layers.Convolutinon1D(in_features=node_num,
                                            kernal_size=self.kernel_size)
        self.s_gcn_e = layers.GraphConvolution(in_features=self.node_num,
                                               out_features=self.node_num)
        self.x_conv = layers.Convolutinon1D(in_features=node_num,
                                            kernal_size=self.kernel_size)
        self.x_gcn_e = layers.GraphConvolution(in_features=self.node_num,
                                               out_features=self.node_num)

        self.x_vae_tras = nn.Linear(self.kernel_size * self.node_num,
                                    self.node_num)
        self.s_vae_tras = nn.Linear(self.kernel_size * self.node_num,
                                    self.node_num)

        self.fusion = nn.Linear(self.node_num * 2, self.node_num)

        # reconstruction network

        self.vae = layers.VariationalAutoencoder(
            node_num=self.node_num,
            hidden_features=self.re_hidden,
            vi_feature=self.vi_feature)

        self.x_vae_traspose = nn.Linear(self.node_num,
                                        self.kernel_size * self.node_num)

        # feature extraction
        self.gcn_d = layers.GraphConvolution(in_features=self.node_num,
                                             out_features=self.node_num)
        self.transpose_conv = layers.ConvolutinonTranspose1D(
            in_features=node_num, kernal_size=self.kernel_size)
        self.gcn_d_std = layers.GraphConvolution(in_features=self.node_num,
                                                 out_features=self.node_num)
        self.transpose_conv_std = layers.ConvolutinonTranspose1D(
            in_features=node_num, kernal_size=self.kernel_size)

        # Discriminator
        self.mask_discriminator = layers.Discriminator(
            node_num=self.node_num,
            kernel_size=kernel_size,
            vi_feature=self.vi_feature,
            hidden_features=self.dis_hidden)

        self.args = args