예제 #1
0
test_accs = np.zeros(
    (len(datasets), 3, args.num_trials, args.epochs, 2))  #loss val, acc test
for d, dataset in enumerate(datasets):
    print("dataset: ", dataset)
    if dataset == 'CS':
        with open(
                'data_coauthor_' + dataset + '/' + dataset +
                '/curvatures_and_idx/curv_idx', 'rb') as f:
            X, Y, idx_train, idx_val, idx_test, orc, frc = pickle.load(f)
            A = np.random.uniform(size=(X.shape[0], X.shape[0]))
            ollivier_curv_vals, forman_curv_vals = csr_matrix(
                A.shape).toarray(), csr_matrix(A.shape).toarray()

            for tup in orc.G.edges:
                i, j = tup[0], tup[1]
                ollivier_curv_vals[i][j] = map_curvature_val(
                    orc.G[i][j]['ricciCurvature'], alpha=4)
                forman_curv_vals[i][j] = map_curvature_val(
                    frc.G[i][j]['formanCurvature'], alpha=4)

    else:
        ########################################### TRYING TO REPLACE A WITH RICCI CURVATURE ###########################################
        G = G_from_data_file(dataset)
        args.data = dataset
        X, Y, A, idx_train, idx_val, idx_test = utils.load_data(args)
        ollivier_curv_vals, forman_curv_vals = csr_matrix(
            A.shape).toarray(), csr_matrix(A.shape).toarray()
        orc = OllivierRicci(G, alpha=0.5, verbose="INFO")
        orc.compute_ricci_curvature()
        frc = FormanRicci(G)
        frc.compute_ricci_curvature()
        for tup in orc.G.edges:
예제 #2
0
# ************************************************************
# calculate edge features
# ************************************************************
vals = []
EYE = scipy.sparse.eye(K, dtype=np.float32, format='coo')



########################################### TRYING TO REPLACE A WITH RICCI CURVATURE ###########################################
ollivier_curv_vals, forman_curv_vals = csr_matrix(A.shape).toarray(), csr_matrix(A.shape).toarray()

for tup in frc.G.edges:
    i,j = tup[0], tup[1]
    #ollivier_curv_vals[i][j] = map_curvature_val(orc.G[i][j]['ricciCurvature'])
    forman_curv_vals[i][j] = map_curvature_val(frc.G[i][j]['formanCurvature'])

#edge_feat_list = [ollivier_curv_vals,forman_curv_vals]
edge_feat_list = [forman_curv_vals]
########################################### END ###########################################
for mat in edge_feat_list:
    vals.append((mat+mat.transpose()+EYE>0).astype(np.float32))
    if args.encode_edge_direction:
        vals.append((mat+EYE>0).astype(np.float32))
        vals.append((mat.transpose()+EYE>0).astype(np.float32))
vals = [sparse.as_coo(x) for x in vals]
vals = sparse.stack(vals, axis=0)
vals = vals.todense()
vals = aml_graph.normalize_adj(vals, args.edge_norm, assume_symmetric_input=False)

temp_vals = vals