Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: undefined to_sparse() function #2

Open
puigde opened this issue Apr 29, 2024 · 0 comments
Open

docs: undefined to_sparse() function #2

puigde opened this issue Apr 29, 2024 · 0 comments

Comments

@puigde
Copy link

puigde commented Apr 29, 2024

In the code snippet below This second example is about loading the dataset as a GNN with random data and classes:

import random
from torch_geometric.utils import from_networkx
import numpy as np

def to_torch_randomdata(dataset, features, classes):
    for d in dataset:
        G = d["graph"]
        for n in G.nodes():
            G.nodes[n]['features'] = list(np.random.rand(features).astype(np.float32))
            G.nodes[n]['classes'] = random.randint(0,classes - 1)
        gnn = from_networkx(G)
        gnn = to_sparse(gnn)
        yield {"name": d["name"], "gnn": gnn}
        
dataset = to_torch_randomdata(load_dataset("<dataset_folder>"), 10, 2)

The function to_sparse is undefined.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant