missing keys in dict when batching custom heterogeneous data #4102
Answered
by
rusty1s
nabsabraham
asked this question in
Q&A
-
hi @rusty1s! I'm trying to set up a heterogeneous graph of from torch_geometric.data import HeteroData
num_cells = xx.shape[0]
num_genes = xx.shape[1]
mydata = HeteroData()
mydata['cell'].x = nn.Embedding(embedding_dim=64, num_embeddings=num_cells)
mydata['gene'].x = nn.Embedding(embedding_dim=64, num_embeddings=num_genes)
mydata['cell'].train_mask = train_mask
mydata['cell'].val_mask = val_mask
mydata['cell'].num_nodes = num_cells
mydata['gene'].num_nodes = num_genes
mydata['cell', 'express', 'gene'].edge_index = edge_index
mydata['cell', 'express', 'gene'].edge_attr = edge_weight
mydata['cell'].y = torch.tensor(obs['age'].values) I use the kwargs = {'batch_size': 1024, 'num_workers': 2, 'persistent_workers': True}
mytrain_input_nodes = ('cell', mydata['cell'].train_mask)
myval_input_nodes = ('cell', mydata['cell'].val_mask)
train_loader = HGTLoader(mydata, num_samples=[32] * 2, shuffle=True,
input_nodes=mytrain_input_nodes, **kwargs)
out = next(iter(train_loader))
I tried to debug (below) and found the output of the sampler is missing my
Another related question, when would you use |
Beta Was this translation helpful? Give feedback.
Answered by
rusty1s
Feb 21, 2022
Replies: 1 comment 1 reply
-
You should make sure that there also exists edges from |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
nabsabraham
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You should make sure that there also exists edges from
"gene"
to"cell"
, e.g., viadata = transforms.ToUndirected()(data)
.