tkipf / gcn

Implementation of Graph Convolutional Networks in TensorFlow
MIT License
7.14k stars 2k forks source link

multiple "support" #54

Open AkandaAshraf opened 6 years ago

AkandaAshraf commented 6 years ago

Hi

I was wondering about the "num_supports=1".

Is it possible to input multiple supports? Let's say for a graph with different types of connections can I input two different adj matrices / supports?

       support = list()
       support.append(sp.coo_matrix(adj1))
       support.append(sp.coo_matrix(adj2))

It looks like that the "sparse_to_tuple" function is written to deal with list inputs and also the convolve operation seem to have (layers.py line#240):

        supports.append(support)
    output = tf.add_n(supports)

Did you intend to have this feature which is to be able to deal with two different adj matrices for the same graph?

I tried to pass a support with a list of two adj matrices, however, I am getting an error when I tried to do this:

File "D:/gcn/gcn-master/gcn/akanda.py", line 488, in experiment outs = sess.run([model.opt_op, model.loss, model.accuracy], feed_dict=feed_dict) File "C:\Program Files\Python36\lib\site-packages\tensorflow\python\client\session.py", line 900, in run run_metadata_ptr) File "C:\Program Files\Python36\lib\site-packages\tensorflow\python\client\session.py", line 1104, in _run np_val = np.asarray(subfeed_val, dtype=subfeed_dtype) File "C:\Program Files\Python36\lib\site-packages\numpy\core\numeric.py", line 492, in asarray return array(a, dtype, copy=False, order=order) ValueError: setting an array element with a sequence.

Thanks a lot!

tkipf commented 6 years ago

Yes this feature was intended. Unfortunately the API of tensorflow changed in the meantime which gives you this error I suppose. You might want to try feeding the adjacency matrices as we did in the ‚recommender-gcn‘ repository by Rianne van den Berg (I currently don’t have Internet access while writing this, but if you look this up on Google you should find it). Hope this helps! On Tue 28. Aug 2018 at 18:09 AkandaAshraf notifications@github.com wrote:

Hi

I was wondering about the "num_supports=1".

Is it possible to input multiple supports? Let's say for a graph with different types of connections can I input two different adj matrices / supports?

   support = list()
   support.append(sp.coo_matrix(adj1))
   support.append(sp.coo_matrix(adj2))

It looks like that the "sparse_to_tuple" function is written to deal with list inputs also the convolve operation seem to have (layers.py line#240):

    supports.append(support)
output = tf.add_n(supports)

Did you intend to have this feature which is to be able to deal with two different adj matrices for a same graph?

I tried to pass a support with a list of two adj matrices, however I am getting an error when I tried to do this:

File "D:/gcn/gcn-master/gcn/akanda.py", line 488, in experiment outs = sess.run([model.opt_op, model.loss, model.accuracy], feed_dict=feed_dict) File "C:\Program Files\Python36\lib\site-packages\tensorflow\python\client\session.py", line 900, in run run_metadata_ptr) File "C:\Program Files\Python36\lib\site-packages\tensorflow\python\client\session.py", line 1104, in _run np_val = np.asarray(subfeed_val, dtype=subfeed_dtype) File "C:\Program Files\Python36\lib\site-packages\numpy\core\numeric.py", line 492, in asarray return array(a, dtype, copy=False, order=order) ValueError: setting an array element with a sequence.

Thanks a lot!

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/tkipf/gcn/issues/54, or mute the thread https://github.com/notifications/unsubscribe-auth/AHAcYOgvMJECfyfmWzFAFRkfIgU2EDRaks5uVXkogaJpZM4WQCQc .

guotong1988 commented 6 years ago

multiple "support" means multiple graph?

tkipf commented 6 years ago

Each ‘support’ is an adjacency matrix, so you can see it as multiple graphs, yes. On Tue 11. Sep 2018 at 09:03 Tong Guo notifications@github.com wrote:

multiple "support" means multiple graph?

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/tkipf/gcn/issues/54#issuecomment-420184664, or mute the thread https://github.com/notifications/unsubscribe-auth/AHAcYB4zA7K9PY1LH22qYYPcm5h-ovwBks5uZ25lgaJpZM4WQCQc .

guotong1988 commented 6 years ago

Thx for your reply!