Giter Club home page Giter Club logo

Comments (2)

williamleif avatar williamleif commented on August 20, 2024 2

Hi yes, this part of the code is extremely hard to parse, though it is doing what it needs to.. The main complicating thing (which made directly implementing the psuedo-code exactly as written impossible in Tensorflow) was TensorFlow's (at the time) lack of support for dynamic compute graphs. The concatenation in line 5 of algorithm 1 also really complicates implementation in TensorFlow.

For the sake of my sanity and others' understanding, I made an easier to understand reference implementation in PyTorch if you're interested: https://github.com/williamleif/graphsage-simple

I did not actually write the aggregate(...) function in this TensorFlow version, but I'll try to explain a bit, though it is really confusing (thus why I made the easier-to-read pytorch version):

The reason for the two loops is that to get the final "output" representation of a node, we need representations of that node at each of the preceding layers (in the notation of Algorithm 1, to get the iteration k=K representation of a node, we need its representations for iterations 1...K_1). So basically the first iteration of the inner-loop (when layer=0 and hop=0) corresponds to getting the iteration k=1 representations for the set of nodes that we want to have embeddings for at the final "layer"/iteration k=K. And the inner-loop when layer=0, hop=1 computers the iteration k=1 embeddings for nodes that are needed at iteration k=2, and the layer=0, hop=2 inner-loop computes the embeddings for the nodes that are only used at iteration k=1. This is horrendously confusing imo haha T_T, but it works and avoids unnecessary computations compared to more naive TensorFlow implementations.

from graphsage.

RexYing avatar RexYing commented on August 20, 2024

Yes that complication is for efficiency reasons...

from graphsage.

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.