G RAPH T RAVERSAL WITH T ENSOR F UNCTIONALS : A META -A LGORITHM FOR S CALABLE L EARNING
A BSTRACT
Graph Representation Learning (GRL) methods have impacted ﬁelds from chemistry to social science.
However, their algorithmic implementations are specialized to speciﬁc use-cases e.g. message passing methods are run differently from node embedding ones.
Despite their apparent differences, all these methods utilize the graph structure, and therefore, their learning can be approximated with stochastic graph traversals.
We propose Graph Traversal via Tensor Functionals (GTTF), a unifying meta-algorithm framework for easing the implementation of diverse graph algorithms and enabling transparent and efﬁcient scaling to large graphs.
GTTF is founded upon a data structure (stored as a sparse tensor) and a stochastic graph traversal algorithm (described using tensor operations).
The algorithm is a functional that accept two functions, and can be specialized to obtain a variety of GRL models and objectives, simply by changing those two functions.
We show for a wide class of methods, our algorithm learns in an unbiased fashion and, in expectation, approximates the learning as if the specialized implementations were run directly.
With these capabilities, we scale otherwise non-scalable methods to set state-of-the-art on large graph datasets while being more efﬁcient than existing GRL libraries – with only a handful of lines of code for each method specialization.
GTTF and its various GRL implementations are on: https://github.com/isi-usc-edu/gttf
I NTRODUCTION
Graph representation learning (GRL) has become an invaluable approach for a variety of tasks, such as node classiﬁcation (e.g., in biological and citation networks; Veliˇckovi´c et al.
; Kipf &
Welling (2017); Hamilton et al.
; Xu et al.
, edge classiﬁcation (e.g., link prediction for social and protein networks; Perozzi et al.
Grover & Leskovec (2016)), entire graph classiﬁcation (e.g., for chemistry and drug discovery Gilmer et al.
; Chen et al.
(2018a)), etc.
In this work, we propose an algorithmic uniﬁcation of various GRL methods that allows us to re-implement existing GRL methods and introduce new ones, in merely a handful of code lines per method.
Our algorithm (abbreviated GTTF, Section 3.2), receives g raphs as input, t raverses them using efﬁcient t ensor 1 operations, and invokes specializable f unctions during the traversal.
We show function specializations for recovering popular GRL methods (Section 3.3).
Moreover, since GTTF is stochastic, these specializations automatically scale to arbitrarily large graphs, without careful derivation per method.
Importantly, such specializations, in expectation, recover unbiased gradient estimates of the objective w.r.t.
model parameters.
G    1 1     
  10 2 3111    
12 4 2 10 2 1(d) Walk Forest. GTTF in- vokes A F once per green GTTF uses a data structure (cid:98) A ( Compact Adjacency , Section 3.1): a sparse encoding of the adjacency matrix.
Node v contains its neighbors in row (cid:98)
A [ v ] (cid:44) (cid:98)
A v , notably, in the ﬁrst degree ( v ) columns of (cid:98) A [ v ] .
This encoding allows stochastic graph traversals using standard tensor operations.
GTTF is a functional , as it accepts functions A CCUMULATE F N and B IAS F N , respectively, to be provided by each GRL specialization to accumulate necessary information for computing the objective, and optionally to parametrize sampling procedure p ( v ’s neighbors | v ) .
The traversal internally constructs a walk forest as part of the computation graph.
Figure 1 depicts the data structure and the computation.
From a generalization perspective, GTTF shares similarities with Dropout (Srivastava et al., 2014).
Our contributions are: (i)
A stochastic graph traversal algorithm (GTTF) based on tensor operations that inherits the beneﬁts of vectorized computation and libraries such as PyTorch and Tensorﬂow.
(ii)
We list specialization functions, allowing GTTF to approximately recover the learning of a broad class of popular GRL methods.
(iii)
We prove that this learning is unbiased, with controllable variance. Wor this class of methods, (iv) we show that GTTF can scale previously-unscalable GRL algorithms, setting the state-of-the-art on a range of datasets.
Finally, (v) we open-source GTTF along with new stochastic traversal versions of several algorithms, to aid practitioners from various ﬁelds in applying and designing state-of-the-art GRL methods for large graphs.
R ELATED W ORK
We take a broad standpoint in summarizing related work to motivate our contribution.
Method
F a m il y
S c a l e
L e a r n i n g
Models
GCN, GAT
MP (cid:55) exact node2vec
NE (cid:51) approx
WYS
NE (cid:55) exact
Stochastic Sampling Methods
SAGE
MP (cid:51) approx
FastGCN
MP (cid:51) approx
LADIES
MP (cid:51) approx
GraphSAINT MP (cid:51) approx
CluterGCN
MP (cid:51) heuristic
Software Frameworks
PyG
Both inherits / reDGL
Both implements
Algorithmic Abstraction (ours)
GTTF
Both (cid:51) approx
Models for GRL have been proposed, including message passing ( MP ) algorithms, such as Graph Convolutional Network (GCN) (Kipf & Welling, 2017), Graph Attention (GAT) (Veli ˇ ckovi ´ c et al., 2018); as well as node embedding ( NE ) algorithms, including node2vec (Grover & Leskovec, 2016), WYS (Abu-El-Haija et al., 2018); among many others (Xu et al., 2018;
Wu et al., 2019; Perozzi et al., 2014).
The full-batch GCN of
Kipf & Welling (2017), which drew recent attention and has motivated many MP algorithms, was not initially scalable to large graphs, as it processes all graph nodes at every training step.
To scale MP methods to large graphs, researchers proposed
Stochastic Sampling Methods that, at each training step, assemble a batch constituting subgraph(s) of the (large) input graph.
Some of these sampling methods yield unbiased gradient estimates (with some variance) including SAGE (Hamilton et al., 2017), FastGCN
(Chen et al., 2018b), LADIES (Zou et al., 2019), and GraphSAINT (Zeng et al., 2020).
On the other hand, ClusterGCN (Chiang et al., 2019) is a heuristic in the sense that, despite its good performance, it provides no guarantee of unbiased gradient estimates of the full-batch learning.
Gilmer et al.
(2017) and Chami et al. (2021) generalized many GRL models into Message Passing and Auto-Encoder frameworks.
These frameworks prompt bundling of GRL methods under Software Libraries , like PyG (Fey & Lenssen, 2019) and DGL (Wang et al., 2019), offering consistent interfaces on data formats.
We now position our contribution relative to the above.
Unlike generalized message passing (Gilmer et al., 2017), rather than abstracting the model computation, we abstract the learning algorithm.
As a result, GTTF can be specialized to recover the learning of MP as well as NE methods.
Morever, unlike
Software Frameworks, which are re-implementations of many algorithms and therefore inherit the scale and learning of the copied algorithms, we re-write the algorithms themselves, giving them new properties (memory and computation complexity), while maintaining (in expectation) the original algorithm outcomes.
Further, while the listed Stochastic Sampling Methods target MP algorithms (such as GCN, GAT, alike), as their initial construction could not scale to large graphs, our learning algorithm applies to a wider class of GRL methods, additionally encapsulating NE methods.
Finally, while some NE methods such as node2vec (Grover & Leskovec, 2016) and DeepWalk (Perozzi et al., 2014) are scalable in their original form, their scalability stems from their multi-step process: sample many (short) random walks, save them to desk, and then learn node embeddings using positional embedding methods (e.g., word2vec, Mikolov et al.
– they are sub-optimal in the sense that their ﬁrst step (walk sampling) takes considerable time (before training even starts) and also places an artiﬁcial limit on the number of training samples (number of simulated walks), whereas our algorithm conducts walks on-the-ﬂy whilst training.
G RAPH T RAVERSAL VIA T ENSOR F UNCTIONALS (GTTF)
At its core, GTTF is a stochastic algorithm that recursively conducts graph traversals to build representations of the graph.
We describe the data structure and traversal algorithm below, using the following notation.
G =
( V, E ) is an unweighted graph with n = | V | nodes and m =
| E | edges, described as a sparse adjacency matrix A ∈ { 0 , 1 } n × n .
Without loss of generality, let the nodes be zero-based numbered i.e. V = { 0 , . . .
, n − 1 } .
We denote the out-degree vector δ ∈ Z n – it can be calculated by summing over rows of A as δ u = (cid:80) v ∈ V A [ u, v ] .
We assume δ u > 0 for all u ∈ V : pre-processing can add self-connections to orphan nodes.
B denotes a batch of nodes.
3. D ATA S TRUCTURE
Internally, GTTF relies on a reformulation of the adjacency matrix, which we term CompactAdj (for "Compact Adjacency", Figure 1c).
It consists of two tensors:
δ ∈
Z n , a dense out-degree vector (ﬁgure 1c, right) 2.
(cid:98)
A ∈ Z n × n , a sparse edge-list matrix in which the row u contains left-aligned δ u non-zero values.
The consecutive entries { (cid:98) A [ u, 0] , (cid:98)
A [ u, 1] , . . .
, (cid:98) A [ u, δ u − 1] } contain IDs of nodes receiving an edge from node u
The
remaining | V | − δ u are left unset therefore, (cid:98) A only occupies O ( m ) memory when
stored
as a sparse matrix (
Figure 1c,
left CompactAdj allows us to concisely describe stochastic traversals using standard tensor operations.
To uniformly sample a neighbor to node u ∈ V , one can draw r ∼ U [0 ..
( δ u − 1)] , then get the neighbor
ID with (cid:98) A [ u, r ] .
In vectorized form, given node batch B and access to continuous U [0 , 1) , we sample neighbors for each node in B as: R ∼ U [0 , 1) b , where b = | B | , then B (cid:48) =
(cid:98) A [ B, (cid:98) R ◦ δ
[ B ] (cid:99) ] is a b -sized vector, with B (cid:48)
u containing a neighbor of B u , ﬂoor operation (cid:98) .
(cid:99) is applied element-wise, and ◦ is Hadamard product.
3. S TOCHASTIC T RAVERSAL F UNCTIONAL A LGORITHM
Our traversal algorithm starts from a batch of nodes.
It expands from each into a tree, resulting in a walk forest rooted at the nodes in the batch, as depicted in Figure 1d.
In particular, given a node batch B , the algorithm instantiates | B | seed walkers, placing one at every node in B .
Iteratively, each walker ﬁrst replicates itself a fanout ( f ) number of times.
Each replica then samples and transitions to a neighbor.
This process repeats a depth ( h ) number of times.
Therefore, each seed walker becomes the ancestor of a f -ary tree with height h .
Setting f = 1 recovers traditional random walk.
In practice, we provide ﬂexibility by allowing a custom fanout value per depth.
Functional Traverse is listed in Algorithm 1.
It accepts: a batch of nodes 2 ; a list of fanout values
F (e g. to F = [3 , 5] samples 3 neighbors per u ∈ B , then 5 neighbors for each of those); and more notably, two functions: A CCUMULATE F N and B IAS F N .
These functions will be called by the functional on every node visited along the traversal, and will be passed relevant information (e.g. the path taken from root seed node).
Custom settings of these functions allow recovering wide classes of graph learning methods.
At a high-level, our functional can be used in the following manner:
Construct model & initialize parameters (e g. to random).
Deﬁne A CCUMULATE F N and B IAS F N . 2.
Repeat (many rounds): i. Reset accumulation information (from previous round) and then sample batch B ⊂ V . ii.
Invoke Traverse on ( B , A CCUMULATE F N , B IAS F N ), which invokes the F N ’s, allowing the ﬁrst to accumulate information sufﬁcient for running the model and estimating an objective.
iii.
Use accumulated information to: run model, estimate objective, apply learning rule (e.g. SGD).
A CCUMULATE F N is a function that is used to track necessary information for computing the model and the objective function.
For instance, an implementation of DeepWalk (Perozzi et al., 2014) on top of GTTF, specializes A CCUMULATE F N to measure an estimate of the sampled softmax likelihood of nodes’ positional distribution, modeled as a dot-prodct of node embeddings.
On the other hand, GCN (Kipf & Welling, 2017) on top of GTTF uses it to accumulate a sampled adjacency matrix, which it passes to the underlying model (e.g. 2-layer GCN) as if this were the full adjacency matrix.
B IAS F N is a function that customizes the sampling procedure for the stochastic transitions.
If provided, it must yield a probability distribution over nodes, given the current node and the path that lead to it.
If not provided, it defaults to U , transitioning to any neighbor with equal probability.
It can be deﬁned to read edge weights, if they denote importance, or more intricately, used to parameterize a second order Markov Chain (Grover & Leskovec, 2016), or use neighborhood attention to guide sampling (Veliˇckovi´c et al., 2018), as discussed in the Appendix.
3. S OME S PECIALIZATIONS OF A CCUMULATE F N & B IAS F N 3.3. M ESSAGE P ASSING : G RAPH C ONVOLUTIONAL VARIANTS
These methods, including (Kipf & Welling, 2017; Hamilton et al., 2017; Wu et al., 2019; Abu-ElHaija et al., 2019; Xu et al., 2018) can be approximated by by initializing (cid:101)
A to an empty sparse n × n matrix, then invoking Traverse (Algorithm 1) with u = B ; F to list of fanouts with size h ;
Thus
A CCUMULATE F N and B IAS F N become:
[Equation]
where (cid:126) 1 n is an n -dimensional all-ones vector, and negative indexing T − k is the k th last entry of
T .
If a node has been visited through the stochastic traversal, then it already has fanout number of neighbors and N O R EVISIT B IAS ensures it does not get revisited for efﬁciency, per line 5 of
Algorithm 1.
Afterwards, the accumulated stochastic (cid:101)
A will be fed 3 into the underlying model e [Equation] g. for a 2-layer GCN of Kipf & Welling (2017):
[Equation]
[Equation]
Lastly, h should be set to the receptive ﬁeld required by the model for obtaining output d L -dimensional features at the labeled node batch.
In particular, to the number of GC layers multiplied by the number of hops each layers access.
E.g. hops= 1 for GCN but customizable for MixHop and SimpleGCN.
3.3. N ODE E MBEDDINGS
Given a batch of nodes B ⊆ V , DeepWalk 4 can be implemented in GTTF by ﬁrst initializing loss L to the contrastive term estimating the partition function of log-softmax:
[Equation]
where (cid:104) .
(cid:105) is dot-product notation, Z ∈ R n × d is the trainable embedding matrix with Z i ∈ R d is d -dimensional embedding for node u ∈ V .
In our experiments, we estimate the expectation by taking 5 samples and we set the negative distribution P n ( V = v ) ∝ δ 34 v , following Mikolov et al.
The functional is invoked with no B IAS F N and A CCUMULATE F N =
[Equation]
where hyperparameter C indicates maximum window size (inherited from word2vec, Mikolov et al., 2013), in the summation on k does not access invalid entries of T as C T (cid:44) min( C, T .size ) , the scalar fraction (cid:0) C − k +1 C (cid:1) is inherited from context sampling of word2vec (Section 3.1 in Levy et al., 2015), and rederived for graph context by Abu-El-Haija et al.
(2018), and η [ u ] stores a scalar per node on the traversal Walk Forest, which defaults to 1 for non-initialized entries, and is used as a correction term.
DeepWalk conducts random walks (visualized as a straight line) whereas our walk tree has a branching factor of f .
Setting fanout f = 1 recovers DeepWalk’s simulation, though we found f >outperforms within fewer iterations
e.g. f = 5 , within 1 epoch, outperforms DeepWalk’s published implementation.
Learning can be performed using the accumulated L as: Z ← Z − (cid:15) ∇ Z L ;
T HEORETICAL A NALYSIS
Due to space limitations, we include the full proofs of all propositions in the appendix.
4. E STIMATING k TH POWER OF TRANSITION MATRIX
We show that it is possible with GTTF to accumulate an estimate of transition T matrix to power k .
Let Ω denote the walk forest generated by GTTF, Ω( u, k, i ) as the i th node in the vector of nodes at depth k of the walk tree rooted at u ∈ B , and t u,v,ki as the indicator random variable 1 [Ω( u, k, i ) = v ] .
Let the estimate of the k th power of the transition matrix be denoted (cid:98) T k .
Entry (cid:98) T ku,v should be an unbiased estimate of T ku,v for u ∈ B , with controllable variance.
We deﬁne:
[Equation]
The fraction in Equation 6 counts the number of times the walker starting at u visits v in Ω , divided by the total number of nodes visited at the k th step from u .
Proposition 1.
(U NBIASED T K ) (cid:98) T ku,v as deﬁned in Equation 6, is an unbiased estimator of T ku,v
Proposition 2.
(V ARIANCE T K )
Variance of our estimate is upper-bounded: Var [ (cid:98) T ku,v ] ≤ 1 4 f k
Naive computation of k th powers of the transition matrix can be efﬁciently computed via repeated sparse matrix-vector multiplication.
Speciﬁcally, each column of T k can be computed in O ( mk ) , where m is the number of edges in the graph.
Thus, computing T k in its entirety can be accomplished in O ( nmk ) .
However, this can still become prohibitively expensive if the graph grows beyond a certain size.
GTTF on the other hand can estimate T k in time complexity independent of the size of the graph, (Prop. 8), with low variance.
Transition matrix powers are useful for many GRL methods.
(Qiu et al., 2018)
4. U NBIASED L EARNING
As a consequence of Propositions 1 and 2, GTTF enables unbiased learning with variance control for classes of node embedding methods, and provides a convergence guarantee for graph convolution models under certain simplifying assumptions. We start by analyzing node embedding methods. Speciﬁcally, we cover two general types.
The ﬁrst is based on matrix factorization of the power-series of transition matrix.
and the second is based on cross-entropy objectives, e.g., like DeepWalk (Perozzi et al., 2014), node2vec (Grover & Leskovec, 2016), These two are shown in Proposations 3 and
Proposition 3.
(U NBIASED TF ACTORIZATION )
Suppose L = 12 || LR − (cid:80)
k c k T k
|| 2 F , i.e. factorization objective that can be optimized by gradient descent by calculating ∇ L,R L , where c k ’s are scalar coefﬁcients.
Let its estimate (cid:98) L = 12 || LR − (cid:80) k c k (cid:98) T k || 2 F , where (cid:98) T is obtained by GTTF according to
Equation 6. Then E [ ∇ L,R (cid:98) L ] = ∇ L,R L . Proposition 4. (U NBIASED L EARN NE) Learning node embeddings Z ∈ R n × d with objective function L , decomposable as L ( Z ) = (cid:80)
u ∈ V L 1 ( Z, u ) − (cid:80) u,v ∈ V (cid:80)
k
L 2 ( T k , u, v ) L 3 ( Z, u, v ) , where L 2 is linear over T k , then using (cid:98) T k yields an unbiased estimate of ∇ Z L .
Generally, L 1 (and L 3 ) score the similarity between disconnected (and connected) nodes u and v .
The above form of L covers a family of contrastive learning objectives that use cross-entropy loss and assume a logistic or (sampled-)softmax distributions.
We provide, in the Appendix, the decompositions for the objectives of DeepWalk (Perozzi et al., 2014), node2vec (Grover & Leskovec, 2016) and
WYS (Abu-El-Haija et al., 2018).
Proposition 5.
(U NBIASED MP)
Given input activations, H ( l − 1) , graph conv layer ( l ) can use rooted adjacency (cid:101)
A accumulated by R OOTED A DJ
A CC (1), to provide unbiased pre-activation output, i.e. E (cid:104) ◦
A k H ( l − 1) W
( l ) (cid:105) = (cid:16) D (cid:48) − 1 / 2 A (cid:48) D (cid:48) − 1 / 2 (cid:17) k H
( l − 1) W ( l ) , with A (cid:48) and D (cid:48) deﬁned in (3).
Proposition 6.
(U NBIASED L EARN MP)
If objective to a graph convolution model is convex and
Lipschitz continous, with minimizer θ ∗ , then utilizing GTTF for graph convolution converges to θ ∗ .
4. C OMPLEXITY A NALYSIS
Proposition 7.
S TORAGE complexity of GTTF is O ( m + n ) .
Proposition 8.
T IME complexity of GTTF is O ( bf h ) for batch size b , fanout f , and depth h .
Proposition 8 implies the speed of computation is irrespective of graph size.
Methods implemented in GTTF inherit this advantage.
For instance, the node embedding algorithm WYS (Abu-El-Haija et al., 2018) is O ( n 3 ) , however, we apply its GTTF implementation on large graphs.
E XPERIMENTS
We conduct experiments on 10 different graph datasets, listed in in Table 1.
We experimentally demonstrate the following.
(1) Re-implementing baseline method using GTTF maintains performance.
(2) Previously-unscalable methods, can be made scalable when implemented in GTTF.
(3) GTTF achieves good empirical performance when compared to other sampling-based approaches handdesigned for Message Passing.
(4) GTTF consumes less memory and trains faster than other popular
Software Frameworks for GRL.
To replicate our experimental results, for each cell of the table in our code repository, we provide one shell script to produce the metric, except when we indicate that the metric is copied from another paper.
Unless otherwise stated, we used fanout factor of 3 for GTTF implementations.
Learning rates and model hyperparameters are included in the Appendix.
5. N ODE E MBEDDINGS FOR L INK P REDICTION
In link prediction tasks, a graph is partially obstructed by hiding a portion of its edges.
The task is to recover the hidden edges.
We follow a popular approach to tackle this task: ﬁrst learn node embedding Z ∈ R n × d from the observed graph, then predict the link between nodes u and v with score ∝ Z (cid:62) u Z v .
We use two ranking metrics for evaluations: ROC-AUC, which is a ranking objective: how well do methods rank the hidden edges above randomly-sampled negative edges and Mean Rank.
We re-implement Node Embedding methods, DeepWalk (Perozzi et al., 2014) and WYS (Abu-ElHaija et al., 2018), into GTTF (abbreviated F ).
Table 2 summarizes link prediction test performance.
LiveJournal and Reddit are large datasets, where original implementation of WYS is unable to scale to.
However, scalable F (WYS) sets new state-of-the-art on these datasets.
For PPI and HepTh datasets, we copy accuracy numbers for DeepWalk and WYS from (Abu-El-Haija et al., 2018).
For
LiveJournal, we copy accuracy numbers for DeepWalk and PBG from (Lerer et al., 2019) – note that a well-engineered approach (PBG, (Lerer et al., 2019)), using a mapreduce-like framework, is under-performing compared to F (WYS), which is a few lines specialization of GTTF.
5. M ESSAGE P ASSING FOR N ODE C LASSIFICATION
We implement in GTTF the message passing models: GCN (Kipf & Welling, 2017), GraphSAGE (Hamilton et al., 2017), MixHop (Abu-El-Haija et al., 2019), SimpleGCN (Wu et al., 2019), as their computation is straight-forward.
For GAT (Veliˇckovi´c et al., 2018) and GCNII (Chen et al., 2020), as they are more intricate, we download the authors’ codes, and wrap them as-is with our functional.
We show that we are able to run these models in Table 3 (left and middle), and that GTTF implementations matches the baselines performance.
For the left table, we copy numbers from the published papers.
However, we update GAT to work with TensorFlow 2.0 and we use our updated code (GAT*).
5. E XPERIMENTS COMPARING AGAINST S AMPLING METHODS FOR M ESSAGE P ASSING
We now compare models trained with GTTF (where samples are walk forests) against sampling methods that are especially designed for Message Passing algorithms (GraphSAINT and ClusterGCN), especially since their sampling strategies do not match ours.
Table 3 (right) shows test performance on node classiﬁcation accuracy on a large dataset: Products.
We calculate the accuracy for F (SAGE), but copy from (Hu et al., 2020)
the accuracy for the baselines:
GraphSAINT (Zeng et al., 2020) and ClusterGCN (Chiang et al., 2019) (both are message passing methods); and also node2vec (Grover & Leskovec, 2016) (node embedding method).
[Table]
[Table] [Table]
Speed (
[Table]
Reddit
Products
Reddit
[Table]
DGL 17.
[Table] [Table]
PyG 5. OOM 1. GTTF 1. 750 Time (s) 0.
R O C - A U C framework (node2vec) PyG(node2vec)
In addition to the accuracy metrics discussed above, we also care about computational performance. We compare against software frameworks DGL (Wang et al., 2019) and PyG (Fey & Lenssen, 2019).
These software frameworks offer implementations of many methods.
Table 4 summarizes the following.
First (left), we show time-per-epoch on large graphs of their implementation of
GraphSAGE, compared with GTTF’s, where we make all hyper parameters to be the same (of model architecture, and number of neighbors at message passing layers).
Second (middle), we run their
GCN implementation on small datasets (Cora, Citeseer, Pubmed) to show peak memory usage.
The run times between GTTF, PyG and DGL are similar for these datasets.
The comparison can be found in the Appendix.
While the aforementioned two comparisons are on popular message passing methods, the third (right) chart shows a popular node embedding method: node2vec’s link prediction test ROC-AUC in relation to its training runtime.
C ONCLUSION
We present a new algorithm, Graph Traversal via Tensor Functionals (GTTF) that can be specialized to re-implement the algorithms of various Graph Representation Learning methods.
The specialization takes little effort per method, making it straight-forward to port existing methods or introduce new ones.
Methods implemented in GTTF run efﬁciently as GTTF uses tensor operations to traverse graphs.
In addition, the traversal is stochastic and therefore automatically makes the implementations scalable to large graphs.
We theoretically show that the learning outcome due to the stochastic traversal is in expectation equivalent to the baseline when the graph is observed at-once, for popular
GRL methods we analyze.
Our thorough experimental evaluation conﬁrms that methods implemented in GTTF maintain their empirical performance, and can be trained faster and using less memory even compared to software frameworks that have been thoroughly optimized.  A CKNOWLEDGEMENTS
We acknowledge support from the Defense Advanced Research Projects Agency (DARPA) under award FA8750-17-C-0106.
A PPENDIX A H YPERPARAMETERS
For the general link prediction tasks we used a | B | = | V | , C = 5 , f = 3 , 10 negative samples per edge, Adam optimizer with a learning rate of 0.5, multiplied by a factor of 0.2, every 50 steps, for 200 total iterations.
The differences are listed below.
The Reddit dataset was trained using a starting learning rate of 2.0, decaying 50% every 10 iterations.
The LiveJournal task was trained using a ﬁxed learning rate of 0.001, | B | = 5000 , f = 2 , andnegative samples per edge.
For the node classiﬁcations tasks:
For F ( SimpleGCN ) on Amazon, we use f = [15 , 15] , a batch size of 1024, and a learning rate of 0.02, decaying by a factor 0f 0.2 after 2 and 6 epochs for a total of 25 epochs.
On Reddit, it is the same except f = [25 , 25] For F ( SAGE ) on Amazon we use f = [20 , 10] , a two layer model, a batch size of 256, and ﬁxed learning rates of 0.001 and 0.002 respectively.
On reddit we use f =
[25 , 20] , a ﬁxed learning rate of 0.001, hidden dimension of 256 and a batch size of 1024.
On the Products dataset, we used f = [15 , 10] , a ﬁxed learning learning rate of 0.001 and a batch size of 1024, a hidden dimension of 256 and a ﬁxed learning rate of 0.003. For
GAT (baseline), we follow the authors code and hyperparameters: for Cora and Citeseer, we use Adam with learning rate of 0.005, L2 regularization of 0.0005, 8 attention heads on the ﬁrst layer and 1 attention head on the output layer.
For Pubmed, we use Adam with learning rate of 0.01,
L2 regularization of 0.01, 8 attention heads on the ﬁrst layer and 8 attention heads on the output layer.
For F ( GAT ) , we use the same aforementioned hyperparameters, a fanout of 3 and traversal depth of 2 (to cover two layers) i.e. F = [3 , 3] .
For F ( GCN ) , we use the authors’ recommended hyperparameters.
Learning rate of 0.005, 0.001 L2 regularization, and F = [3 , 3] , for all datasets.
For both methods, we apply “patience” and stop the training if validation loss does not improve for 100 consecutive epochs, reporting the test accuracy at the best validation loss.
For F ( MixHop ) , we wrap the authors’ script and use their hyperparameters.
For F ( GCNII ) , we use F = [5 , 5 , 5 , 5 , 5 , 5] , as their models are deep (64 layers for Cora).
Otherwise, we inherit their network hyperparameters (latent dimensions, number of layers, dropout factor, and their introduced coefﬁcients), as they have tuned them per dataset, but we change the learning rate to 0 .
005 (half of what they use) and we extend the patience from 100 to 1000, and extend the maximum number of epochs from 1500 to 5000 – this is because we are presenting a subgraph at each epoch, and therefore we intuitively want to slow down the learning per epoch, which is similar to the practice when someone applies Dropout to a neural networks.
We re-run their shell scripts, with their code modiﬁed to use the Rooted Adjacency rather than the real adjacency, which is sampled at every epoch.
MLP was trained with 1 layer and a learning rate of 0.01.
B P ROOFS B. P ROOF OF P ROPOSITION
Proof.
E [ [Equation]
B. P ROOF OF P ROPOSITION
Proof. Var [
[Equation]
Since 0 ≤ T ku,v ≤ 1 , then T ku,v (1 −T ku,v ) is maximized with T ku,v = 1 2 .
Hence V ar [ (cid:98) T ku,v ] ≤ 1 4 f k
B. P ROOF OF P ROPOSITION
Proof.
Consider a d -dimensional factorization of (cid:80) k c k T k , where c k ’s are scalar coefﬁcients:
[Equation]
parametrized by L, R (cid:62) ∈ R n × d .
The gradients of L w.r.t.
parameters are: [Equation] [Equation] Given estimate objective L (replacing (cid:98) T with using GTTF-estimated (cid:98) T ):
[Equation]
(cid:12)(cid:12)(cid:12)(cid:12)(cid:12)(cid:12)(cid:12)(cid:12)(cid:12)(cid:12) F . It follows that: [Equation]
Scaling property
of expectation = [Equation] Linearity of expectation
[Equation] (cid:32) [Equation] (cid:88) k
[Equation]
k
[Equation]
Proof of Proposition
[Equation]
The above steps can similarly be used to show E (cid:104) ∇ R
[Equation]
L
[Equation]
= ∇ R L
B. P ROOF OF P ROPOSITION
Proof.
We want to show that E [ ∇ Z L ( (cid:98) T k , Z )]
= ∇ Z L ( T k , Z ) .
Since the terms of L 1 are unaffected by (cid:98) T , they are excluded w.l.g.
from L in the proof.
[Equation]
[Equation]
The following table gives the decomposition for DeepWalk, node2vec, and Watch Your Step.
Node2vec also introduces a biased sampling procedure based on hyperparameters (they name p and q ) instead of uniform transition probabilities.
We can equivalently bias the transitions in GTTF to match node2vec’s.
This would then show up as a change in (cid:98) T k in the objective.
This effect can also be included in the objective by multiplying (cid:104)
Z u , Z v (cid:105) by the probability of such a transition in L 3 .
In this format, the p and q variables appear in the objective and can be included in the optimization.
For
WYS, Q k are also trainable parameters.
Method
L
[Equation]
DeepWalk (cid:18) [Equation] C
[Equation]
Z v (cid:105) )
[Table]
log
[Equation]
V exp
[Equation]
−
[Equation]
C [Equation] Watch Your Step log(1 − [Equation]
L
[Equation]
R v (cid:105) ))
Q k T k log(
[Equation]
L u
[Equation]
R v (cid:105) )) graph embedding methods to demonstrate unbiased learning.
For WYS,
Z u = concatenate ( L u , R u ) .
For methods in which the transition distribution is not uniform, such as node2vec, there are two options for incorporating this distribution in the loss.
The obvious choice is to sample from a biased transition matrix, T u,v = (cid:102) W u,v , where (cid:102) W is the transition weights.
Alternatively, the transition bias can be used as a weight on the objective itself.
This approach is still unbiased as
[Equation]
B. P ROOF OF P ROPOSITION
Proof.
Let (cid:101)
A be the neighborhood patch returned by GTTF, and let (cid:101) .
indicate a measurement based on the sampled graph, (cid:101) A , such as the degree vector, (cid:101) δ , or diagonal degree matrix, (cid:101) D .
For the remainder of this proof, let all notation for adjacency matrices, A or (cid:101) A , and diagonal degree matrices, D or (cid:101) D , and degree vector, δ , refer to the corresponding measure on the graph with self loops e.g. A ← A + I n × n .
We now show that the expectation of the layer output is unbiased.
E (cid:104) ◦
A k H ( l − 1) W ( l ) (cid:105) =
(cid:104) E (cid:104) ◦
A k (cid:105) H ( l − 1) W
( l ) (cid:105) implies that E (cid:104) ◦
A k H ( l − 1) W
( l ) (cid:105) is unbiased if
E (cid:104) ◦
A k (cid:105) =
(cid:0) D
[Equation]
[Equation]
AD −
[Equation]
2 (cid:1) k . E [Equation] Let P u,v,k be the set of all walks { p = ( u, v 1 , ..., v k − 1 , v ) | v i ∈ V } , and let p ∃ (cid:101)
A indicate that the path p exists in the graph given by (cid:101) A .
Let t u,v,k be the transition probability from u to v in k steps, and let t p be the probability of a random walker traversing the graph along path p . [Equation] [Equation] k (cid:89)
[Equation]
f
[Equation] = (cid:88) p ∈P u [Equation] v
[Equation]
{+k k (cid:89) i = 
+}
[ A [ p i
[Equation]
p i +1 ]
[Equation]
[Equation]
i ]
[Equation]
=
[Equation]
Thus, E (cid:104) ◦
A k (cid:105) =
(cid:0) D − 1 /
[Equation] AD [Equation] 1 / 2 (cid:1) k and E (cid:104)
◦
A k H ( l − 1) W
( l ) (cid:105) = (cid:0) D
[Equation] [Equation] AD [Equation]
[Equation] H
[Equation] W [Equation] For writing, we assumed nodes have degree, δ u ≥ f , though the proof still holds if that is not the case as the probability of an outgoing edge being present from u becomes
and the transition probability becomes δ − 1 u i.e. the same as no estimate at all.
B. P ROOF OF P ROPOSITION
GTTF can be seen as a way of applying dropout (Srivastava et al., 2014), and our proof is contingent on the convergence of dropout, which is shown in Baldi & Sadowski (2014).
Our dropout is on the adjacency, rather than the features.
Denote the output of a graph convolution network 5 with H :
[Equation]
We restrict our analysis to GCNs with linear activations.
We are interested in quantifying the change of H as A changes, and therefore the ﬁxed (always visible) features X is placed on the subscript.
Let (cid:101)
A denote adjacency accumulated by GTTF’s R OOTED A DJ
A CC (Eq. 1).
[Equation]
Let A = { (cid:101)
A c } |A| c
=1 denote the (countable) set of all adjacency matrices realizable by GTTF.
For the analysis, assume the graph is α -regular: the assumption eases the notation though it is not needed.
Therefore, degree δ u
= α for all u ∈ V .
Our analysis depends 6 on 1 |A| (cid:80) (cid:101)
A ∈A (cid:101)
A ∝ A .
i.e. the average realizable matrix by GTTF is proportional (entry-wise) to the full adjacency.
This is can be shown when considering one-row at a time: given node u with δ u
= α outgoing neighbors, each of its neighbors has the same appearance probability = 1 δ u .
Summing over all combinations (cid:0) δ u f (cid:1) , makes each edge appear the same frequency = 1 δ u |A| , noting that |A| evenly divides (cid:0) δ u f (cid:1) for all u ∈ V .
We deﬁne a dropout module:
[Equation]
with z ∼ Categorical
[Equation]
where z c acts as Multinoulli selector over the elements of A , with one of its entries set to 1 and all others to zero.
With this deﬁnitions, GCNs can be seen in the droupout framework as: (cid:101) H =
GCN X ( d A ) .
Nonetheless, in order to inherit the analysis of (Baldi & Sadowski, 2014, see their equations 140 & 141), we need to satisfy two conditions which their analysis is founded upon:
(i) E [ GCN X ( d A )]
= GCN X ( A ) : in the usual (feature-wise) dropout, such condition is easily veriﬁed.
(ii) Backpropagated error signal does not vary too much around around the mean, across all realizations of d A .
Condition (i) is satisﬁed due to proof of Proposition 5.
To analyze the error signal, i.e. the gradient of the error w.r.t.
the network, assume
loss function L ( H ) , outputs scalar loss, is λ -Lipschitz continuous.
The Liptchitz continuity allows us to bound the difference in error signal between L ( H ) and L ( (cid:101) H ) :
[Equation]
where (a) is by Lipschitz continuity, (b) is by Cauchy–Schwarz inequality, “w.p.”
means with probability and uses Chebyshev’s inequality, with the following equality because the variance of
T is shown element-wise in proof for Prop. 2.
Finally, we get the last line by dividing both sides over the common term.
This shows that one can make the error signal for the different realizations arbitrarily small, for example, by choosing a larger fanout value or putting (convex) norm constraints on W and X e.g. through batchnorm and/or weightnorm.
Since we can have
[Equation]
with high probability, then the analysis of Baldi & Sadowski (2014) applies.
Effectively, it can be thought of as an online learning algorithm where the elements of A are the stochastic training examples and analyzed per (Bottou, 1998; 2004), as explained by Baldi & Sadowski (2014) (cid:3) .
B. P ROOF OF P ROPOSITION
The storage complexity of CompactAdj is O ( sizeof ( δ ) + sizeof ( (cid:98) A ))
=
O ( n + m ) .
Moreover, for extemely large graphs, the adjacncy can be row-wise partitioned across multiple machines and therefore admitting linear scaling.
However, we acknolwedge that choosing which rows to partition to which machines can drastically affect the performance.
Balanced partitioning is ideal.
It is an NP-hard problem, but many approximations have been proposed.
Nonetheless, reducing inter-communication, when distributing the data structure across machines, is outside our scope.
B. P ROOF OF P ROPOSITION
For each step of GTTF, the computational complexity is O ( bh f ) .
This follows trivially from the
GTTF functional: each nodes in batch ( b of them) builds a tree with depth h and fanout f i.e. with h f tree nodes.
This calculation assumes random number generation, A CCUMULATE F N and B IAS F N take constant time.
The searchsorted function is linear, as it is called on a sorted list: cumulative sum of probabilities.
C A DDITIONAL GTTF I MPLEMENTATIONS C. M ESSAGE P ASSING I MPLEMENTATIONS C.1. G RAPH A TTENTION N ETWORKS
(GAT, V ELI ˇCKOVI ´C ET AL ., 2018)
One can implement GAT by following the previous subsection, utilizing A CCUMULATE F N and
B IAS F N deﬁned in (1) and (2), but just replacing the model (3) by GAT’s:
[Equation]
16) where ◦ is hadamard product and A is an n × n matrix placing a positive scalar (an attention value) on each edge, parametrized by multi-headed attention described in (Veliˇckovi´c et al., 2018).
However, for some high-degree nodes that put most of the attention weight on a small subset of their neighbors, sampling uniformly (with B IAS F N = N O R EVISIT B IAS ) might mostly sample neighbors with entries in A with value ≈ 0 , and could require more epochs for convergence.
However, our ﬂexible functional allows us to propose a sample-efﬁcient alternative, that is in expectation, equivalent to the above:
[Equation]
[Equation]
[Equation]
DGI implementation on GTTF can use A CCUMULATE F N = R OOTED A DJ A CC , deﬁned in (1).
To create the positive graph: it can sample some nodes B ⊂ V .
It would pass to GTTF’s Traverse B , and utilize the accumulated adjacency (cid:98) A for running: GCN ( (cid:98) A, X B ) and GCN ( (cid:98) A, X permute ) , where the second run randomly permutes the order of nodes in X .
Finally, the output of those GCNs can then be fed into a readout function which outputs to a descriminator trying to classify if the readout latent vector correspond to the real, or the permuted features.
C. N ODE E MBEDDING I MPLEMENTATIONS
[Equation]
A simple implementation follows from above:
N2 V A CC (cid:44) D EEP W ALK
A CC ; but override B IAS F N = [Equation] B IAS
[Equation]
(19) where 1 denotes indicator function, p, q > 0 are hyperparameters of node2vec assigning (unnormalized) probabilities for transitioning back to the previous node or to node connected to it.
(cid:104) A [ T − 2 ] , A [ u ] (cid:105) counts mutual neighbors between considered node u and previous T − 2 .
An alternative implementation is to not override B IAS F N but rather fold it into A CCUMULATE F N , as:
[Equation]
Both alternatives are equivalent in expectation.
However, the latter directly exposes the parameters p and q to the objective L : allowing them to be differentiable w.r.t.
L and therefore trainable via gradient descent, rather than by grid-search.
Nonetheless, parameterizing p & q is beyond our scope.
C.2. W ATCH Y OUR S TEP (WYS, A BU -E L -H AIJA ET AL ., 2018)
First, embedding dictionaries R, L ∈ R n × d 2 can be initialized to random.
Then repeatedly over batches B ⊆ V , the loss L can be initialized to estimate the negative part of the objective:
[Equation]
Then call GTTF’s traverse passing the following A CCUMULATE F N = def W YS A CC ( T, u ) : if T.
[Equation]
Q
[Equation]
return [Equation] R (cid:105) ))
D M ISCELLANEOUS D. S ENSITIVITY
The following ﬁgures show the sensitivity of fanout and walk depth for WYS on the Reddit dataset. [Figure]
[Figure]
D. R UNTIME OF GCN ON CITATION NETWORKS
Citation networks (Cora, Citeseer, Pubmed) have been popularized by Kipf & Welling (2017), and for completeness, we report in Figure 4 the runtime versus test accuracy of GCN on these networks.
We compare against PyG, which is optimized for GCN.
We ﬁnd that the methods are somewhat comparable in terms of training time.