When GraphSAGE Meets Pinterest

Edward Ma
Edward Ma
Mar 25 · 3 min read
Photo by Pinterest

In the previous stories, we introduced Introduction to Graph Embeddings, Random Walk in Node Embeddings, and 4 Graph Neural Networks. I would like to further extend to PingSAGE. It was proposed by Ying et al. in 2018. Ying is one of the authors of GraphSAGE (Hamilton et al., 2018). He and his team apply a modified version of GraphSAGE (Hamilton et al., 2018)in the Pinterest dataset.

We will use the following undirected graph to go though PinSAGE (Ying et al., 2018) algorithm. First of all, we have an input graph with Node A, B, C, D, E, and F. From node respective, and every node is a root node while other nodes are neighbor nodes.

Input Graph (Ying et al., 2018)

We will take Node A is an example. The neighbor nodes of node A include nodes B, C, and D. PinSAGE (Ying et al., 2018) use depth-2 convolutions, so we need to aggregate nodes B, C, and D by their neighbor nodes as well.

In the 1-hop layer (i.e., node B, C, and D), we have aggregation function (i.e., CONVOLVE) to aggregate all neighbor nodes. After aggregated neighbor nodes, both target node’s embeddings (i.e., node A) and neighbor nodes’ embeddings (i.e., nodes B, C, and D). Finally, we get a node A’s representation.

How do we get nodes B, C, and D representation? We use the same technique in the previous step but different weighting to get embeddings. You may notice node A exists again in the second layer of neighbor. It is expected as node A is a neighbor node of nodes B, C, and D. If we remove it from aggregation, we ignore the neighbor relations.

Aggregation of Node A (Ying et al., 2018)

Instead of using all neighbors, Ying et al. propose to use an important-based random walk approach to include the most important neighbors only. It not only reduces the computation footprint but also takes accounts into important neighbors.

Overview of neighbor nodes (Ying et al., 2018)

Take Away


Edward Ma

Written by

Edward Ma

Focus in Natural Language Processing, Data Science Platform Architecture. https://makcedward.github.io/

Towards AI

Towards AI, is the world’s fastest-growing AI community for learning, programming, building and implementing AI.

More From Medium

More from Towards AI

More from Towards AI

More from Towards AI

Image Filtering

More from Towards AI

Mar 29 · 8 min read


Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade