ReasonGNN/lrgb-pascalvoc-neuralwalker-walk-length-6
import torch from datasets import load_dataset from torch_geometric.data import Data, Batch from tqdm import tqdm # Load the HuggingFace dataset from hub hf_dataset = load_dataset("samm393/lrgb-pascalvoc-neuralwalker") # Load multiple graphs num_graphs = 10 # Convert each to PyG Data object pyg_graphs = [] for i in tqdm(range(num_graphs), desc="Loading graphs"): hf_row = hf_dataset['train'][i] pyg_dict = {k: torch.tensor(v) if isinstance(v, list) else v for k, v in hf_row.items()}… See the full description on the dataset page: https://huggingface.co/datasets/ReasonGNN/lrgb-pascalvoc-neuralwalker-walk-length-6.
016
import torch
from datasets import load_dataset
from torch_geometric.data import Data, Batch
from tqdm import tqdm
# Load the HuggingFace dataset from hub
hf_dataset = load_dataset("samm393/lrgb-pascalvoc-neuralwalker")
# Load multiple graphs
num_graphs = 10
# Convert each to PyG Data object
pyg_graphs = []
for i in tqdm(range(num_graphs), desc="Loading graphs"):
hf_row = hf_dataset['train'][i]
pyg_dict = {k: torch.tensor(v) if isinstance(v, list) else v for k, v in hf_row.items()}
pyg_data = Data.from_dict(pyg_dict)
pyg_graphs.append(pyg_data)
# Create a batch object
batch = Batch.from_data_list(pyg_graphs)
print(f"Batch object: {batch}")
print(f"Total nodes in batch: {batch.num_nodes}")
print(f"Total edges in batch: {batch.num_edges}")
print(f"Number of graphs in batch: {batch.num_graphs}")
print(f"Batch tensor shape: {batch.batch.shape}") # Maps each node to its graph
print(f"Batched features shape: {batch.x.shape}")
print(f"Batched NeuralWalker embeddings shape: {batch.neuralwalker_embeddings.shape}")Batch object: DataBatch(x=[4827, 14], edge_index=[2, 27318], edge_attr=[27318, 2], y=[4827], neuralwalker_embeddings=[4827, 56], batch=[4827], ptr=[11])
Total nodes in batch: 4827
Total edges in batch: 27318
Number of graphs in batch: 10
Batch tensor shape: torch.Size([4827])
Batched features shape: torch.Size([4827, 14])
Batched NeuralWalker embeddings shape: torch.Size([4827, 56])