gae icon indicating copy to clipboard operation
gae copied to clipboard

Run GAE with my own graph

Open xieximing opened this issue 6 years ago • 2 comments

Hi Thomas! Thanks for your really great work! I try to use my self-designed graph to train this model. I provide the adjacency matrix like this: [[0 1 0 1 0 0 0 0 0 0 0 0 0] [1 0 1 0 0 0 0 0 0 0 0 0 0] [0 1 0 1 0 0 0 0 0 0 0 0 0] [1 0 1 0 1 0 0 0 0 0 0 0 0] [0 0 0 1 0 1 0 0 1 0 0 0 0] [0 0 0 0 1 0 1 0 0 0 0 0 0] [0 0 0 0 0 1 0 1 0 0 0 0 0] [0 0 0 0 0 0 1 0 1 0 0 0 0] [0 0 0 0 1 0 0 1 0 1 0 0 0] [0 0 0 0 0 0 0 0 1 0 1 0 1] [0 0 0 0 0 0 0 0 0 1 0 1 0] [0 0 0 0 0 0 0 0 0 0 1 0 1] [0 0 0 0 0 0 0 0 0 1 0 1 0]]

and this is my input_data code: def creat_my_graph(): G = nx.Graph()

G.add_nodes_from(range(1,5))
G.add_edges_from([[1,2],[2,3],[3,4],[4,1]])


G.add_nodes_from(range(5,10))
G.add_edges_from([(5,6),[6,7],[7,8],[8,9],[9,5]])

G.add_nodes_from(range(10,13))
G.add_edges_from([(10,11),[11,12],[12,13],[13,10]])

G.add_edges_from([(4,5),(9,10)])
nx.draw(G)
adj = nx.adjacency_matrix(G)
features = np.identity(adj.shape[0])
print(adj.todense())
plt.show()
return adj, features

But there is an error: File "/Users/xieximing/android/gae-master_embedding/gae/preprocessing.py", line 59, in ismember rows_close = np.all(np.round(a - b[:, None], tol) == 0, axis=-1) ValueError: operands could not be broadcast together with shapes (0,) (30,1,2)

if I change the adjacency matrix like this: [[0 1 1 1 1 1 0 0 0 0 0 0 0 0 0] [1 0 1 1 1 1 0 0 0 0 0 0 0 0 0] [1 1 0 1 1 1 0 0 0 0 0 0 0 0 0] [1 1 1 0 1 1 0 0 0 0 0 0 0 0 0] [1 1 1 1 0 1 0 0 0 0 0 0 0 0 0] [1 1 1 1 1 0 1 0 0 0 0 0 0 0 0] [0 0 0 0 0 1 0 1 0 0 0 0 0 0 0] [0 0 0 0 0 0 1 0 1 0 0 0 0 0 0] [0 0 0 0 0 0 0 1 0 1 0 0 0 0 0] [0 0 0 0 0 0 0 0 1 0 1 1 1 1 1] [0 0 0 0 0 0 0 0 0 1 0 1 1 1 1] [0 0 0 0 0 0 0 0 0 1 1 0 1 1 1] [0 0 0 0 0 0 0 0 0 1 1 1 0 1 1] [0 0 0 0 0 0 0 0 0 1 1 1 1 0 1] [0 0 0 0 0 0 0 0 0 1 1 1 1 1 0]] this error doesn't show up. I'm quite confused about it.

xieximing avatar Aug 07 '18 20:08 xieximing

Looks like your a in a - b[:, None] is of shape (0,). Maybe step through it using a debugger and see where it goes wrong (i.e. wherea gets this collapsed shape).

tkipf avatar Aug 19 '18 21:08 tkipf

I had this issue as well.

The problem arises when the script makes the validation edges. If your graph is small, then the operation that gets the number of validation edges returns a 0 number.

Long story short, reduce the number of validation/test splits for this graph

ioannisa92 avatar Jul 15 '19 02:07 ioannisa92