Skip to content

我用了tf_geometric 给的例子,但是显示 TypeError: 'int' object is not subscriptable #51

@Dr-Yan78

Description

@Dr-Yan78

coding=utf-8

import numpy as np
import tf_geometric as tfg
import tensorflow as tf

graph = tfg.Graph(
x=np.random.randn(5, 20), # 5 nodes, 20 features,
edge_index=[[0, 0, 1, 3],
[1, 2, 2, 1]] # 4 undirected edges
)

print("Graph Desc: \n", graph)

graph.to_directed(inplace=True) # pre-process edges
print("Processed Graph Desc: \n", graph)
print("Processed Edge Index:\n", graph.edge_index)

Multi-head Graph Attention Network (GAT)

gat_layer = tfg.layers.GAT(units=4, num_heads=4, activation=tf.nn.relu)
output = gat_layer([graph.x,graph.edge_index])
print("Output of GAT: \n", output)


显示,错误TypeError: 'int' object is not subscriptable

附上所使用的库版本:
tensorflow -------2.16.1
scipy ---------- 1.12.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions