Skip to content
Discussion options

You must be logged in to vote

So I think i figured out the first challenge

def graph_data(A, X, labels):

    tg_graphs = []

    for i in range(len(A)):
        coo = coo_matrix(A[i])
        indices = np.vstack((coo.row, coo.col))
        x = [ord(i) for i in X[i]]
        index = torch.LongTensor(indices)
        feature = torch.FloatTensor(x)

        graph = Data(x=feature, edge_index=index, y=labels[i])

        tg_graphs.append(graph)

    return tg_graphs

Where tg_graphs is:

[Data(x=[18], edge_index=[2, 42], y=0.0912047881539918),
 Data(x=[18], edge_index=[2, 42], y=0.0911561592893587),
 Data(x=[17], edge_index=[2, 40], y=0.0939426626061364),
 Data(x=[17], edge_index=[2, 40], y=0.0911476283054859),
 Data(x=[1…

Replies: 2 comments 5 replies

Comment options

You must be logged in to vote
2 replies
@anthonysirico
Comment options

@rusty1s
Comment options

Comment options

You must be logged in to vote
3 replies
@rusty1s
Comment options

@anthonysirico
Comment options

@rusty1s
Comment options

Answer selected by anthonysirico
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants