Code Monkey home page Code Monkey logo

Comments (2)

amznero avatar amznero commented on May 22, 2024

The same problem happened to me a few days ago. I guess the problem may be caused by the MonitoredTrainingSession (MTS, for short).

graph-learn uses MonitoredTrainingSession for init ps(distributed mode in TensorFlow) environment.

But MTS will freeze the TF Graph(not GNN) after the initialization step is completed. So users are not allowed to modify the graph(can't define some new variable/op).

For this issue, after we use trainer.py to init the session, the TF Graph will be frozen, then the model begins to train for n epochs. (No modify here). But when the code goes to save embedding, it will register a new variable for getting source nodes' embeddings(try to modify the TF graph, then raise an error).

For me, I made some modifications on graph_sage.py.

def build(self):
  ...
  pos_src_emb = self.encoders['src'].encode(self.pos_src_ego_tensor)
  pos_dst_emb = self.encoders['dst'].encode(self.pos_dst_ego_tensor)
  neg_dst_emb = self.encoders['dst'].encode(self.neg_dst_ego_tensor)
  
  # some modifications
  self.pos_src_emb = pos_src_emb
  self.pos_dst_emb = pos_dst_emb
  self.neg_dst_emb = neg_dst_emb

  self.loss = self._unsupervised_loss(pos_src_emb, pos_dst_emb, neg_dst_emb)
  ...

...

def node_embedding(self, type):
  iterator = self.ego_flow.iterator
  # remove
  # ego_tensor = self.ego_flow.pos_src_ego_tensor
  # remove
  # src_emb = self.encoders['src'].encode(ego_tensor)
  # add
  src_emb = self.pos_src_emb
  src_ids = self.pos_src_ego_tensor.src.ids
  return src_ids, src_emb, iterator

...

Similar issue on StackOverflow.

from graph-learn.

baoleai avatar baoleai commented on May 22, 2024

The get_node_embedding in trainer.py is only for local training mode now. For distributed training, there is indeed a problem like @amznero said, you can put get_node_embedding in train funciton before session run in trainer.py. There may be a more elegant solution, I will fix it asap:)

from graph-learn.

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.