GithubHelp home page GithubHelp logo

sparse-gcn's Introduction

Sparse graph convolution network

Attention model is based on:

Vaswani, Ashish, et al. "Attention is all you need." Advances in Neural Information Processing Systems. 2017.

Graph Attention Network:

Veličković, Petar, et al. "Graph Attention Networks." arXiv preprint arXiv:1710.10903 (2017).

sparse-gcn's People

Contributors

antoineprv avatar gasse avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

sparse-gcn's Issues

BUG: sparse gradient and coalesce()

Seems specific to CUDA implementation.

import torch
from torch.nn import Parameter
from torch.autograd import grad

import sgat.sparse as sp

cuda = True

_torch = torch.cuda if cuda else torch

# node features
x = _torch.FloatTensor([[1], [2]])

# attention
i = _torch.LongTensor([[0, 0], [0, 1]])
s = (2, 2)
w = Parameter(_torch.FloatTensor([1, 1]))
a = sp.build(i, w.exp(), s)  # softmax

# convolution
x = sp.matmul(a, x)

# normalization
a_norm = sp.matmul(a, _torch.FloatTensor(a.size(0), 1).fill_(1))
a_norm = a_norm.clamp(min=1e-12)  # avoid divide by zero
x /= a_norm.expand_as(x)

print("Forward ok")

print(grad(x.sum(), w, retain_graph=True))

print("Backward ok")
RuntimeError: The size of tensor a (4) must match the size of tensor b (2) at non-singleton dimension 0

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.