You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
with torch.no_grad(): # Initialize lazy modules.
out = model_IKG(data_IKG.x_dict, data_IKG.edge_index_dict)
Then it raises:
Input In [324], in HGT.forward(self, x_dict, edge_index_dict)
29 for conv in self.convs:
30 print(1)
---> 31 x_dict = conv(x_dict, edge_index_dict)
32 print(2)
33 return self.lin(x_dict['symptom'])
Then the error message is:
File ~/.virtualenvs/xlq/lib/python3.8/site-packages/torch/nn/modules/module.py:1102, in Module._call_impl(self, *input, **kwargs)
1098 # If we don't have any hooks, we want to skip the rest of the logic in
1099 # this function, and just call forward.
1100 if not (self._backward_hooks or self._forward_hooks or self._forward_pre_hooks or _global_backward_hooks
1101 or _global_forward_hooks or _global_forward_pre_hooks):
-> 1102 return forward_call(*input, **kwargs)
1103 # Do not call functions when jit is used
1104 full_backward_hooks, non_full_backward_hooks = [], []
File ~/.virtualenvs/xlq/lib/python3.8/site-packages/torch_geometric/nn/conv/message_passing.py:309, in MessagePassing.propagate(self, edge_index, size, **kwargs)
306 for arg in decomp_args:
307 kwargs[arg] = decomp_kwargs[arg][i]
--> 309 coll_dict = self.collect(self.user_args, edge_index,
310 size, kwargs)
312 msg_kwargs = self.inspector.distribute('message', coll_dict)
313 for hook in self._message_forward_pre_hooks.values():
File ~/.virtualenvs/xlq/lib/python3.8/site-packages/torch_geometric/nn/conv/message_passing.py:202, in MessagePassing.collect(self, args, edge_index, size, kwargs)
200 if isinstance(data, Tensor):
201 self.set_size(size, dim, data)
--> 202 data = self.lift(data, edge_index, dim)
204 out[arg] = data
206 if isinstance(edge_index, Tensor):
File ~/.virtualenvs/xlq/lib/python3.8/site-packages/torch_geometric/nn/conv/message_passing.py:172, in MessagePassing.lift(self, src, edge_index, dim)
170 if isinstance(edge_index, Tensor):
171 index = edge_index[dim]
--> 172 return src.index_select(self.node_dim, index)
173 elif isinstance(edge_index, SparseTensor):
174 if dim == 1:
IndexError: index out of range in self
Please help me to fix the problem, much appreciate.
The text was updated successfully, but these errors were encountered:
rickyqiao
changed the title
Raise 'TypeError: __init__() got an unexpected keyword argument 'add_self_loops' when I use HGTConv with my own dataset.
Raise 'IndexError: index out of range in self' when I use HGTConv with my own dataset.
May 3, 2022
In my work, I build the Hetergouenous graph firstly, then I apply the HGTConv as the tutorial shown.
The custom KG is shown as:
HeteroData(
symptom={ x=[39, 128] },
component={ x=[19, 128] },
reason={ x=[17, 128] },
solution={ x=[18, 128] },
(symptom, take_place, component)={ edge_index=[2, 38] },
(symptom, cause_by, reason)={ edge_index=[2, 33] },
(symptom, how_to_fit, solution)={ edge_index=[2, 33] },
(component, component_parallel, component)={ edge_index=[2, 17] }
)
And my code as follow:
class HGT(torch.nn.Module):
def init(self, hidden_channels, out_channels, num_heads, num_layers):
super().init()
model_IKG = HGT(hidden_channels=64, out_channels=5,
num_heads=1, num_layers=1)
with torch.no_grad(): # Initialize lazy modules.
out = model_IKG(data_IKG.x_dict, data_IKG.edge_index_dict)
Then it raises:
Input In [324], in HGT.forward(self, x_dict, edge_index_dict)
29 for conv in self.convs:
30 print(1)
---> 31 x_dict = conv(x_dict, edge_index_dict)
32 print(2)
33 return self.lin(x_dict['symptom'])
Then the error message is:
File ~/.virtualenvs/xlq/lib/python3.8/site-packages/torch/nn/modules/module.py:1102, in Module._call_impl(self, *input, **kwargs)
1098 # If we don't have any hooks, we want to skip the rest of the logic in
1099 # this function, and just call forward.
1100 if not (self._backward_hooks or self._forward_hooks or self._forward_pre_hooks or _global_backward_hooks
1101 or _global_forward_hooks or _global_forward_pre_hooks):
-> 1102 return forward_call(*input, **kwargs)
1103 # Do not call functions when jit is used
1104 full_backward_hooks, non_full_backward_hooks = [], []
File ~/.virtualenvs/xlq/lib/python3.8/site-packages/torch_geometric/nn/conv/hgt_conv.py:159, in HGTConv.forward(self, x_dict, edge_index_dict)
156 v = (v_dict[src_type].transpose(0, 1) @ m_rel).transpose(1, 0)
158 # propagate_type: (k: Tensor, q: Tensor, v: Tensor, rel: Tensor)
--> 159 out = self.propagate(edge_index, k=k, q=q_dict[dst_type], v=v,
160 rel=self.p_rel[edge_type], size=None)
161 out_dict[dst_type].append(out)
163 # Iterate over node-types:
File ~/.virtualenvs/xlq/lib/python3.8/site-packages/torch_geometric/nn/conv/message_passing.py:309, in MessagePassing.propagate(self, edge_index, size, **kwargs)
306 for arg in decomp_args:
307 kwargs[arg] = decomp_kwargs[arg][i]
--> 309 coll_dict = self.collect(self.user_args, edge_index,
310 size, kwargs)
312 msg_kwargs = self.inspector.distribute('message', coll_dict)
313 for hook in self._message_forward_pre_hooks.values():
File ~/.virtualenvs/xlq/lib/python3.8/site-packages/torch_geometric/nn/conv/message_passing.py:202, in MessagePassing.collect(self, args, edge_index, size, kwargs)
200 if isinstance(data, Tensor):
201 self.set_size(size, dim, data)
--> 202 data = self.lift(data, edge_index, dim)
204 out[arg] = data
206 if isinstance(edge_index, Tensor):
File ~/.virtualenvs/xlq/lib/python3.8/site-packages/torch_geometric/nn/conv/message_passing.py:172, in MessagePassing.lift(self, src, edge_index, dim)
170 if isinstance(edge_index, Tensor):
171 index = edge_index[dim]
--> 172 return src.index_select(self.node_dim, index)
173 elif isinstance(edge_index, SparseTensor):
174 if dim == 1:
IndexError: index out of range in self
Please help me to fix the problem, much appreciate.
The text was updated successfully, but these errors were encountered: