tensorflow / tensorflow/gnn

Not possible to sample twice along same edge_set?

Open
#827 1 comment 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
1.5k
Forks
204
Avg merge
13m
Merged PRs (30d)
1

Description

Hi,

I have a heterogeneous graph where I would like to sample twice along the same edge set, i.e. starting from A we can reach B, C, D, E, F, G:

  B - C
 / \
A - D - E
 \
  F - G

This should be possible, according to the documentation:

# Store builder at level of "author written papers":
builder = tfgnn.SamplingSpecBuilder(schema).seed('author').sample(10, 'writes')
path1 = builder.sample(5, 'cited_by')
path2 = builder.sample(3, 'written_by').sample('writes')

proto = (tfgnn.SamplingSpecBuilder.join([path1, path2]).sample(10, 'cited_by')
         .build())

# The above `Join()` can be made less verbose with:
proto = path1.Join([path2]).sample(10, 'cited_by').build()

In the above example, cited_by is clearly used twice.

However when I try this I get the error message:

ValueError: The name ... is used 2 times in the model. All layer names should be unique.

To reproduce:

I can easily reproduce this in the ogbn notebook, by replacing:

  papers_cited_from_seed = seed.sample(sizes["cites"], "cites")

with

  papers_cited_from_seed = seed.sample(sizes["cites"], "cites").sample(sizes["cites"], "cites")

or equivalently

  papers_cited_from_seed = seed.sample([sizes["cites"], sizes["cites"]], "cites")

to obtain the error:

ValueError: The name "cites" is used 2 times in the model. All layer names should be unique.

Is this a bug or is this intentional? It's possible I'm thinking along the wrong lines.

Many thanks.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the linked ogbn_mag_e2e.ipynb reproduction and read the referenced SamplingSpecBuilder documentation around sampling and Join(). Then inspect the sampling-spec builder and the layer-name generation path to determine why repeated "cites" sampling creates duplicate names. Done means establishing whether repeated edge-set sampling works as documented, with a regression test or clarified limitation.

Written by the indexing model from the issue text.

Assessment

Tech stack
python, tensorflow
Domain
machine-learning
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.