我正在尝试通过 dgl 和 torch 构建动态异构图。但是,它失败了。我尝试过多种变体,但似乎都不起作用。有什么想法吗?
这是完整的错误消息:
Traceback (most recent call last):
File "D:\PythonProjects\GNNtest\venv\TGCN.py", line 124, in <module>
graph = create_graph(data, num_nodes=num_nodes)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "D:\PythonProjects\GNNtest\venv\TGCN.py", line 109, in create_graph
dst_shareholder = th.tensor(data['shareholder'].values)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: can't convert np.ndarray of type numpy.object_. The only supported types are: float64, float32, float16, complex64, complex128, int64, int32, int16, int8, uint8, and bool.
Process finished with exit code 1
我已将所有节点数据转换为 int32。可能导致此错误的原因是什么,如何找出并构建图表?
看起来您的
np.ndarray
类型为 numpy.object_
您可以尝试将其转换为浮动:
import numpy as np
your_array = np.vstack(your_array).astype(np.float)
然后通过dgl和torch构建动态异构图。