<jupyter_start><jupyter_text>Main file karateThis is the main file for the karate classification task<jupyter_code>import tensorflow as tf
import numpy as np
import gnn_utils
import GNN as GNN
import Net_Karate as n
from scipy.sparse import coo_matrix

##### GPU & stuff config
import os

os.environ['CUDA_VISIBLE_DEVICES'] = "0"
config = tf.ConfigProto()
config.gpu_options.allow_growth = True

############# training set ################


E, N, labels = gnn_utils.load_karate()
inp, arcnode, graphnode = gnn_utils.from_EN_to_GNN(E, N)

# set input and output dim, the maximum number of iterations, the number of epochs and the optimizer
threshold = 0.01
learning_rate = 0.01
state_dim = 5
tf.reset_default_graph()
input_dim = inp.shape[1]
output_dim = labels.shape[1]
max_it = 50
num_epoch = 10000
optimizer = tf.train.AdamOptimizer

# initialize state and output network
net = n.Net(input_dim, state_dim, output_dim)

# initialize GNN
param = "st_d" + str(state_dim) + "_th" + str(threshold) + "_lr" + str(learning_rate)
print(param)

tensorboard = False

g = GNN.GNN(net, input_dim, output_dim, state_dim,  max_it, optimizer, learning_rate, threshold, graph_based=False, param=param, config=config,
            tensorboard=tensorboard)

# train the model
count = 0

######

for j in range(0, num_epoch):
    _, it = g.Train(inputs=inp, ArcNode=arcnode, target=labels, step=count)

    if count % 30 == 0:
        print("Epoch ", count)
        print("Training: ", g.Validate(inp, arcnode, labels, count))

        # end = time.time()
        # print("Epoch {} at time {}".format(j, end-start))
        # start = time.time()

    count = count + 1

# evaluate on the test set
#print("\nEvaluate: \n")
#print(g.Evaluate(inp_test[0], arcnode_test[0], labels_test, nodegraph_test[0])[0])<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.13366336633663367, 'fraction_numerical': 0.01485148514851485, 'mean_word_length': 4.579754601226994, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '555024', 'license': 'BSD-3-Clause', 'n_tokens_mistral': 664, 'n_tokens_neox': 631, 'n_words': 172, 'path': '_downloads/f5751364a4cd414e7ea0e82c288799ae/GNN_Karate.ipynb', 'repo_name': 'mtiezzi/gnn_site', 'size': '1818'}