Example #1
0
def learn(config, data):
    start = timeit.default_timer()
    train(config, data)
    end = timeit.default_timer()
    print('Time : {0}'.format(end - start))


if __name__ == '__main__':
    start = timeit.default_timer()

    path = "/Users/siddharthashankardas/Purdue/Dataset/Karate/"

    from GNN_configuration import getSettings, load_data_DGL
    load_config = {
        "input_path": path,
        "labeled_only": True,
        "dataset_name": "karate"
    }
    data = load_data_DGL(load_config)

    print(data)

    gnn_settings = getSettings(load_config['dataset_name'])
    gnn_settings['output_path'] = path

    train(gnn_settings, data)
    #load_saved(gnn_settings,data)

    end = timeit.default_timer()
    print('Time : {0}'.format(end - start))
Example #2
0
def learn():
    if (LEARNING_data_config['algorithm'] == 'GCN_DGL'):
        from GNN.GCN_DGL.GCN_DGL_main import learn
        from GNN_configuration import getSettings, load_data_DGL
        if LEARNING_data_config["dataset_name"] == "karate":
            LEARNING_data_config["vectorize"] = ""
        LEARNING_data_config['input_path'] = dataset_info[LEARNING_data_config[
            'dataset_name']]['path'] + LEARNING_data_config["vectorize"] + "/"
        data = load_data_DGL(LEARNING_data_config)

        gnn_settings = getSettings(LEARNING_data_config['dataset_name'], data)
        gnn_settings['output_path'] = dataset_info[
            LEARNING_data_config['dataset_name']]['output_path']

        learn(gnn_settings, data)

    elif (LEARNING_data_config['algorithm'] == 'GSAGE_DGL'):
        from GNN.GSAGE_DGL.GSAGE_DGL_main import learn
        from GNN_configuration import getSettings, load_data_DGL

        if LEARNING_data_config["dataset_name"] == "karate":
            LEARNING_data_config["vectorize"] = ""
        LEARNING_data_config['input_path'] = dataset_info[LEARNING_data_config['dataset_name']]['path'] + \
                                             LEARNING_data_config["vectorize"] + "/"
        data = load_data_DGL(LEARNING_data_config)

        gnn_settings = getSettings(LEARNING_data_config['dataset_name'])
        gnn_settings['output_path'] = dataset_info[
            LEARNING_data_config['dataset_name']]['output_path']

        learn(gnn_settings, data)

    elif (LEARNING_data_config['algorithm'] == 'GAT_DGL'):
        from GNN.GAT_DGL.GAT_DGL_main import learn
        from GNN_configuration import getSettings, load_data_DGL

        if LEARNING_data_config["dataset_name"] == "karate":
            LEARNING_data_config["vectorize"] = ""
        LEARNING_data_config['input_path'] = dataset_info[LEARNING_data_config['dataset_name']]['path'] + \
                                             LEARNING_data_config["vectorize"] + "/"
        data = load_data_DGL(LEARNING_data_config)

        gnn_settings = getSettings(LEARNING_data_config['dataset_name'])
        gnn_settings['output_path'] = dataset_info[
            LEARNING_data_config['dataset_name']]['output_path']

        learn(gnn_settings, data)

    elif (LEARNING_data_config['algorithm'] == 'FC'):
        from GNN.FNN_PT_TF_Keras.FC import learn
        from GNN_configuration import getSettings, load_data_DGL

        if LEARNING_data_config["dataset_name"] == "karate":
            LEARNING_data_config["vectorize"] = ""
        LEARNING_data_config['input_path'] = dataset_info[LEARNING_data_config['dataset_name']]['path'] + \
                                             LEARNING_data_config["vectorize"] + "/"
        data = load_data_DGL(LEARNING_data_config)

        gnn_settings = getSettings(LEARNING_data_config['dataset_name'])
        gnn_settings['output_path'] = dataset_info[
            LEARNING_data_config['dataset_name']]['output_path']

        learn(gnn_settings, data)

    else:
        print("this GNN is not incorporated yet")
        sys.exit(0)

    return