예제 #1
0
    def build(self,
              hiddens=[32],
              activations=['relu'],
              dropout=0.5,
              l2_norm=0.,
              lr=0.01,
              use_bias=False):

        #         if self.kind == "P":
        #             raise RuntimeError(f"Currently {self.name} only support for tensorflow backend.")

        if self.kind == "T":
            with tf.device(self.device):
                self.model = tfGCN(self.graph.n_attrs,
                                   self.graph.n_classes,
                                   hiddens=hiddens,
                                   activations=activations,
                                   dropout=dropout,
                                   l2_norm=l2_norm,
                                   lr=lr,
                                   use_bias=use_bias,
                                   experimental_run_tf_function=False)
        else:
            self.model = pyGCN(self.graph.n_attrs,
                               self.graph.n_classes,
                               hiddens=hiddens,
                               activations=activations,
                               dropout=dropout,
                               l2_norm=l2_norm,
                               lr=lr,
                               use_bias=use_bias).to(self.device)
예제 #2
0
    def build(self,
              hiddens=[16],
              activations=['relu'],
              dropout=0.5,
              l2_norm=5e-4,
              lr=0.01,
              use_bias=False):

        if self.kind == "T":
            with tf.device(self.device):
                self.model = tfGCN(self.graph.n_attrs,
                                   self.graph.n_classes,
                                   hiddens=hiddens,
                                   activations=activations,
                                   dropout=dropout,
                                   l2_norm=l2_norm,
                                   lr=lr,
                                   use_bias=use_bias)
        else:
            self.model = pyGCN(self.graph.n_attrs,
                               self.graph.n_classes,
                               hiddens=hiddens,
                               activations=activations,
                               dropout=dropout,
                               l2_norm=l2_norm,
                               lr=lr,
                               use_bias=use_bias).to(self.device)
예제 #3
0
    def build(self,
              hiddens=[16],
              activations=['relu'],
              dropout=0.5,
              lr=0.01,
              l2_norm=5e-4,
              use_bias=False,
              p1=1.,
              p2=1.,
              n_power_iterations=1,
              epsilon=0.03,
              xi=1e-6):

        if self.kind == "T":
            with tf.device(self.device):
                self.model = tfGCN(self.graph.n_attrs,
                                   self.graph.n_classes,
                                   hiddens=hiddens,
                                   activations=activations,
                                   dropout=dropout,
                                   l2_norm=l2_norm,
                                   lr=lr,
                                   use_bias=use_bias)
                self.index_all = tf.range(self.graph.n_nodes, dtype=self.intx)
        else:
            raise NotImplementedError

        self.p1 = p1  # Alpha
        self.p2 = p2  # Beta
        self.xi = xi  # Small constant for finite difference
        # Norm length for (virtual) adversarial training
        self.epsilon = epsilon
        self.n_power_iterations = n_power_iterations  # Number of power iterations