GithubHelp home page GithubHelp logo

Comments (3)

PetarV- avatar PetarV- commented on August 28, 2024

Hi Minjie,

Thank you for the kind words and your interest in GAT!

I believe what you are probably missing is adding the identity matrix to the adjacency. The raw sparse matrix, as extracted by Thomas Kipf's code, does not have ones on the diagonal (they only add it in post-processing).

Disclaimer: We have played around with the sparse layer only for the purposes of Pubmed, so cannot guarantee exact reproducibility compared to the dense layer. However, I just now executed the sparse model on Cora once and managed to get 83.7% on the test set.

P.S. If you manage to get a good-looking version of the sparse code running, could you consider submitting a pull request with a models/sp_gat.py and sp_execute_cora.py? All the versions I have implemented seem too hacky for inclusion in this repository. :)

Thanks,
Petar

from gat.

jermainewang avatar jermainewang commented on August 28, 2024

Hi Petar,

Thank you for your reply! I figured out what I missed. When I fed the sparse adj matrix to tensorflow, I incorrectly packed the row index and column index. Basically, I used following codes to convert the adj matrix to tf.SparseTensor:

def process_adj_sp(adj):
  num_nodes = adj.shape[0]
  adj = adj + sp.eye(num_nodes)  # self-loop
  adj[adj > 0.0] = 1.0
  if not sp.isspmatrix_coo(adj):
    adj = adj.tocoo()
  adj = adj.astype(np.float32)
  indices = np.vstack((adj.col, adj.row)).transpose()  # This is where I made a mistake, I used (adj.row, adj.col) instead
  return tf.SparseTensor(indices=indices, values=adj.data, dense_shape=adj.shape)

It worked perfectly now. I think you implementation looks fine for me. I did make some changes, but the main sp_attn_head function followed your implementation. I could try make a pull request later.

Best regards,
Minjie

from gat.

KnightOfTheMoonlight avatar KnightOfTheMoonlight commented on August 28, 2024

Hi, @jermainewang and @PetarV- , I just have a quick simple question. Why would you suggest a sparse adjacency bias matrix? To deal with what scenarios? I tried, it seems not to work for speedup.

from gat.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.