Comments (3)
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.
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.
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)
- How to output labels updated after this algorithm?
- output the uodated label
- ValueError: Dimensions must be equal, but are 122904 and 12 for 'mul' (op: 'Mul') with input shapes: [122904], [12].
- multi-graph node classsification HOT 3
- adj_to_bias "return -1e9 * (1.0 - mt)" term
- Weighted adjacency graphs HOT 2
- The attention value of all edges of a node is almost equal HOT 2
- t-SNE HOT 2
- Unseen node embedding
- Usage with image data HOT 2
- how to sample neighbours(nodes)?
- issue in Generating test.index file HOT 3
- Please follow this to get the "Solution to creating the files under the data folder"
- Need help in creating evaulation metrics
- How to batch large datasets to apply GAT?
- transform to other scope dataset
- Why using undirected graph for transductive learning?
- Why using undirected graph for transductive learning?
- How to get node embeddings? HOT 1
- Code fails with tensorflow-2.9.1: module 'tensorflow' has no attribute 'layers' HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from gat.