docstr: learning_rate: Initial learning rate
  epochs: Number of epochs to train
  hidden1: Number of units in hidden layer 1
  dropout: Dropout rate (1 - keep probability)
  weight_decay: Weight for L2 loss on embedding matrix
  early_stopping: Tolerance for early stopping (# of epochs)
  max_degree: Maximum Chebyshev polynomial degree
docstr_tok: ["learning_rate",":","Initial","learning","rate","epochs",":","Number","of","epochs","to","train","hidden1",":","Number","of","units","in","hidden","layer","1","dropout",":","Dropout","rate","(","1","-","keep","probability",")","weight_decay",":","Weight","for","L2","loss","on","embedding","matrix","early_stopping",":","Tolerance","for","early","stopping","(","#","of","epochs",")","max_degree",":","Maximum","Chebyshev","polynomial","degree"]
code: def __init__(
      self,
      graph,
      learning_rate=0.01,
      epochs=200,
      hidden1=16,
      dropout=0.5,
      weight_decay=5e-4,
      early_stopping=10,
      max_degree=3,
      clf_ratio=0.1,
  ):
      """
      learning_rate: Initial learning rate
      epochs: Number of epochs to train
      hidden1: Number of units in hidden layer 1
      dropout: Dropout rate (1 - keep probability)
      weight_decay: Weight for L2 loss on embedding matrix
      early_stopping: Tolerance for early stopping (# of epochs)
      max_degree: Maximum Chebyshev polynomial degree
      """
      self.graph = graph
      self.clf_ratio = clf_ratio
      self.learning_rate = learning_rate
      self.epochs = epochs
      self.hidden1 = hidden1
      self.dropout = dropout
      self.weight_decay = weight_decay
      self.early_stopping = early_stopping
      self.max_degree = max_degree
  
      self.preprocess_data()
      self.build_placeholders()
      # Create model
      self.model = models.GCN(
          self.placeholders,
          input_dim=self.features[2][1],
          hidden1=self.hidden1,
          weight_decay=self.weight_decay,
          logging=True,
      )
      # Initialize session
      self.sess = tf.Session()
      # Init variables
      self.sess.run(tf.global_variables_initializer())
  
      cost_val = []
  
      # Train model
      for epoch in range(self.epochs):
          t = time.time()
          # Construct feed dictionary
          feed_dict = self.construct_feed_dict(self.train_mask)
          feed_dict.update({self.placeholders["dropout"]: self.dropout})
  
          # Training step
          outs = self.sess.run(
              [self.model.opt_op, self.model.loss, self.model.accuracy],
              feed_dict=feed_dict,
          )
  
          # Validation
          cost, acc, duration = self.evaluate(self.val_mask)
          cost_val.append(cost)
  
          # Print results
          print(
              "Epoch:",
              "%04d" % (epoch + 1),
              "train_loss=",
              "{:.5f}".format(outs[1]),
              "train_acc=",
              "{:.5f}".format(outs[2]),
              "val_loss=",
              "{:.5f}".format(cost),
              "val_acc=",
              "{:.5f}".format(acc),
              "time=",
              "{:.5f}".format(time.time() - t),
          )
  
          if epoch > self.early_stopping and cost_val[-1] > np.mean(
              cost_val[-(self.early_stopping + 1) : -1]
          ):
              print("Early stopping...")
              break
      print("Optimization Finished!")
  
      # Testing
      test_cost, test_acc, test_duration = self.evaluate(self.test_mask)
      print(
          "Test set results:",
          "cost=",
          "{:.5f}".format(test_cost),
          "accuracy=",
          "{:.5f}".format(test_acc),
          "time=",
          "{:.5f}".format(test_duration),
      )
  
file_path: OpenNE/src/openne/gcn/gcnAPI.py
imports: import numpy
  from .utils import *
  from .None import models
  import time
  import scipy.sparse
  import tensorflow
label_desc: Use image node_id 1 to create a new GCN object from inherited base classes: object with example: obj = GCN(graph, learning_rate, epochs, hidden1, dropout, weight_decay, early_stopping, max_degree, clf_ratio)