dgl
dgl copied to clipboard
how gatconv runs on multi-type edges
import dgl import numpy as np import torch as th from dgl.nn import GATConv
u = [0, 1, 0, 2, 1] v = [0, 1, 4, 3, 2] w = [2, 4, 1, 3, 4] g = dgl.heterograph({('A', 'r', 'B'): (th.tensor(u), th.tensor(v)), ('A', 'c', 'B'):(th.tensor(u), th.tensor(w))})
u_feat = th.tensor(np.random.rand(3, 5).astype(np.float32)) v_feat = th.tensor(np.random.rand(5, 10).astype(np.float32)) gatconv = GATConv((5,10), 2, 3, allow_zero_in_degree=True) res = gatconv(g, (u_feat, v_feat))
when I run this piece of code, I got the error: TypeError: new(): invalid data type 'str' what should I do to run without error,thanks!