Giter Club home page Giter Club logo

Comments (8)

laurimi avatar laurimi commented on August 20, 2024

I was able to save the models to disk once I realized the graph adjacency and the features were also being written, as they are defined via tf.Constant. This was pushing the size of the graph over the limit. To avoid saving these constants, I used tf.placeholder in their place instead.

The change for supervised models can be seen in this commit in my fork. Happy to put in a pull request if you think there are no obvious downsides.

from graphsage.

RexYing avatar RexYing commented on August 20, 2024

Hi, sorry for the late reply since we are at conference.

What you said is indeed the case. Using placeholder for adj will solve the problem. However, we were concerned that there would be significant overhead when feeding in the same np array at each iteration.
In fact when I was using GraphSAGE for extremely large datasets (10^9 scale), I set the adj as a variable, and feed it in only at the start of training/validation/test.

But of course ideally we would want tensorflow to avoid the overhead when feeding the same array without modifications, so that placeholder would be the most elegant solution.

Rex

from graphsage.

williamleif avatar williamleif commented on August 20, 2024

@RexYing what is the final word on this? I suppose our current implementation in master branch is the simplest, but has the issue that the adjacency matrix is treated as part of the graph. I don't think having the adjacency as a placeholder is best because of the data I/O overhead, but maybe we should have a helper function or something that makes it easier to save the model?

from graphsage.

laurimi avatar laurimi commented on August 20, 2024

Shouldn't it be enough to assign the adjacency matrix placeholder once, before starting the training loop? Further I/O could be avoided also for validation/test sets if another instance of the learned model is created, and only the learned weights are copied to this instance when validation/testing is to be performed. Copying the weights should be orders of magnitude cheaper than swapping the adjacency matrix.

EDIT: I guess a clarification is in order. As far as I can tell from observed behaviour, I think if you do

adjacency_ph = tf.placeholder(tf.int32, shape=(size,), name='adjacency_ph')
adjacency = tf.Variable(adjacency_ph, trainable=False, name='adjacency')

and then outside the training loop run the assignment, e.g.: sess.run(tf.global_variables_initializer(), feed_dict={adjacency_ph: adj}) you are 1) only assigning to adjacency once, not on every iteration of the training loop and 2) still preventing the value of adjacency being written to the GraphDef by using the placeholder.

from graphsage.

williamleif avatar williamleif commented on August 20, 2024

@RexYing do you have thoughts on @laurimi's solution above? You have more experience dealing with this I/O overhead issue, but her solution seems to check out and it would be nice to not have the adjacency as part of the GraphDef.

(Btw, I am traveling and won't be able to test and push anything to master for at least a few days if this solution should be merged in).

from graphsage.

RexYing avatar RexYing commented on August 20, 2024

@laurimi I tested and it does work. Thanks for pointing it out. Would be happy to take the pull request.
Or I could do it myself if you are busy.

Thanks
Rex

from graphsage.

laurimi avatar laurimi commented on August 20, 2024

@RexYing Pull request sent. I decided to only apply the placeholder it for the adjacency matrix. It should be possible to do the same for the features as well, but I did not want to mess around with the model files since I don't feel so confident for now making modifications there.

from graphsage.

RexYing avatar RexYing commented on August 20, 2024

Thank very much for the contribution!

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.