I used the tutorial code from [Tutorial] (https://www.dgl.ai/release/2019/08/28/release.htm]l)
and run this code.
from dgl.data.chem import Tox21
from dgl import model_zoo
dataset = Tox21()
model = model_zoo.chem.load_pretrained('GCN_Tox21') # Pretrained model loaded
model.eval()
smiles, g, label, mask = dataset[0]
feats = g.ndata.pop('h')
label_pred = model(g, feats)
print(smiles) # CCOc1ccc2nc(S(N)(=O)=O)sc2c1
print(label_pred[:, mask != 0]) # Mask non-existing labels
# tensor([[-0.7956, 0.4054, 0.4288, -0.5565, -0.0911,
# 0.9981, -0.1663, 0.2311, -0.2376, 0.9196]])
However, it doesn’t work.
Loading previously saved dgl graphs…
Pretrained model loaded
Traceback (most recent call last):
File “mini_batch_tutorial.py”, line 9, in
feats = g.ndata.pop(‘h’)
File “/home/yoshida/.dotfiles/.pyenv/versions/anaconda3-5.0.0/envs/dgl/lib/python3.7/_collections_abc.py”, line 795, in pop
value = self[key]
File “/home/yoshida/.dotfiles/.pyenv/versions/anaconda3-5.0.0/envs/dgl/lib/python3.7/site-packages/dgl/view.py”, line 60, in getitem
return self._graph.get_n_repr(self._nodes)[key]
KeyError: ‘h’
Blockquote
How should I solve this?