TensorFlowにおけるグラフニューラルネットワーク
Google Researchは、TensorFlow上でグラフニューラルネットワーク(GNN)を実装・学習するためのライブラリ「TF-GNN」をオープンソースで公開し、不規則な関係構造を持つデータへの機械学習適用を促進する。
キーポイント
TF-GNNのリリース
Google Researchが、TensorFlow上でグラフニューラルネットワークを構築・学習するためのライブラリ「TensorFlow GNN (TF-GNN)」をオープンソースで公開した。
グラフ構造データへの対応
従来のMLが扱いにくかった、交通網、生産ネットワーク、知識グラフ、ソーシャルネットワークなど、不規則な関係(グラフ構造)を持つデータを扱えるようにする。
実用性と拡張性の重視
大規模な産業用グラフデータを効率的に処理できる設計であり、研究者と実務者の両方が利用できることを目指している。
GoogleによるAI基盤整備の一環
主要な機械学習フレームワークであるTensorFlowのエコシステムを強化し、グラフベースのAI研究と応用を広く促進する意図がある。
TensorFlow GNN 1.0のリリース
TensorFlow GNN 1.0(TF-GNN)は大規模なGNN構築のための実用テスト済みライブラリで、TensorFlowでのモデリングとトレーニング、巨大データストアからの入力グラフ抽出をサポートしています。
異種グラフへの対応
TF-GNNは異種グラフ(オブジェクトと関係のタイプが異なるノードとエッジの集合で表現される)に特化して構築されており、現実世界のオブジェクトと関係を自然に表現できます。
GraphTensorの役割
TensorFlow内ではグラフはtfgnn.GraphTensorオブジェクトで表現され、グラフ構造とノード・エッジ・グラフ全体に付随する特徴を格納し、tf.data.Datasetやtf.functionで第一級オブジェクトとして扱われます。
影響分析・編集コメントを表示
影響分析
このリリースは、グラフ構造データという重要なデータ形式に対する機械学習のアクセス性を大幅に高める。TensorFlowという主要プラットフォーム上での標準的な実装を提供することで、グラフニューラルネットワークの研究開発と実務への応用を加速させ、推薦システム、知識発見、ネットワーク分析など多様な分野への波及効果が期待される。
編集コメント
主要フレームワークにおける標準実装の提供は、技術の民主化と普及において極めて重要。グラフAIという専門性の高い領域への参入障壁を下げ、実世界の複雑な関係性をモデリングする応用が広がる契機となる発表。
TF-GNNライブラリは、様々な抽象化レベルでグラフニューラルネットワーク(Graph Neural Networks: GNN)を構築・学習することをサポートしています。
最も高いレベルでは、ユーザーはライブラリに同梱されている、Kerasレイヤーで表現された定義済みモデルのいずれかを利用できます。研究文献からの少数のモデルコレクションに加えて、TF-GNNは高度に設定可能なモデルテンプレートを提供しており、これは我々が社内の多くの問題において強力なベースラインを提供するとわかったモデリングの選択肢を厳選したものです。テンプレートはGNNレイヤーを実装しており、ユーザーはKerasレイヤーを初期化するだけで済みます。
最も低いレベルでは、ユーザーはグラフ上でデータをやり取りするためのプリミティブ(例えば、ノードからそのすべての外向きエッジへデータをブロードキャストしたり、すべての内向きエッジからノードへデータをプーリングしたりする(例えば、受信メッセージの合計を計算する))を用いて、一からGNNモデルを記述することができます。TF-GNNのグラフデータモデルは、特徴量や隠れ状態に関して、ノード、エッジ、そして入力グラフ全体を同等に扱うため、上記で議論したMPNN(Message Passing Neural Network)のようなノード中心のモデルだけでなく、より一般的な形式のGraphNetsも直感的に表現することができます。これは、コアTensorFlowの上にモデリングフレームワークとしてKerasを使用して行うこともできますが、必須ではありません。詳細および中間レベルのモデリングについては、TF-GNNのユーザーガイドとモデルコレクションを参照してください。
学習オーケストレーション
上級ユーザーはカスタムモデル学習を自由に行えますが、TF-GNN Runnerは一般的なケースにおけるKerasモデルの学習オーケストレーションを簡潔に行う方法も提供しています。簡単な呼び出しは以下のようになります:
runner = tfgnn.fit(...)
runner.run(...)Runnerは、分散学習やCloud TPU上での固定形状のためのtfgnn.GraphTensorパディングなど、機械学習における一般的な課題に対するすぐに使えるソリューションを提供します。単一タスクでの学習(上記で示した通り)を超えて、複数(2つ以上)のタスクを組み合わせた共同学習もサポートしています。例えば、教師なしタスクを教師ありタスクと混合することで、最終的な連続表現(または埋め込み)にアプリケーション固有の帰納バイアスを反映させることができます。呼び出し側は、タスク引数をタスクのマッピングで置き換えるだけで済みます:
tasks = {
"node_classification": tfgnn.NodeClassification(...),
"graph_regression": tfgnn.GraphRegression(...),
}さらに、TF-GNN Runnerには、モデルの帰属分析に使用する統合勾配法の実装も含まれています。統合勾配法の出力は、観測されたGraphTensorと同じ接続性を持つGraphTensorですが、その特徴量は勾配値に置き換えられており、値が大きいほどGNNの予測への寄与が大きいことを示します。ユーザーは勾配値を調べることで、自身のGNNがどの特徴量を最も使用しているかを確認できます。
結論
要約すると、我々はTF-GNNがTensorFlowにおけるGNNの大規模な応用を推進し、この分野のさらなる革新を促進するのに役立つことを願っています。もっと知りたい方は、人気のあるOGBN-MAGベンチマークを用いたColabデモ(ブラウザ上で実行可能、インストール不要)をお試しください。他のユーザーガイドやColabを閲覧したり、論文をご覧になることもできます。
謝辞
TF-GNNリリース1.0は、Google Research: Sami Abu-El-Haija, Neslihan Bulut, Bahar Fatemi, Johannes Gasteiger, Pedro Gonnet, Jonathan Halcrow, Liangze Jiang, Silvio Lattanzi, Brandon Mayer, Vahab Mirrokni, Bryan Perozzi, Anton Tsitsulin, Dustin Zelle、Google Core ML: Arno Eigenwillig, Oleksandr Ferludin, Parth Kothari, Mihir Paradkar, Jan Pfeifer, Rachael Tamakloe、そしてGoogle DeepMind: Alvaro Sanchez-Gonzalez and Lisa Wangによる共同開発でした。
原文を表示
Posted by Dustin Zelle, Software Engineer, Google Research, and Arno Eigenwillig, Software Engineer, CoreML

Objects and their relationships are ubiquitous in the world around us, and relationships can be as important to understanding an object as its own attributes viewed in isolation — take for example transportation networks, production networks, knowledge graphs, or social networks. Discrete mathematics and computer science have a long history of formalizing such networks as *graphs)*, consisting of *nodes* connected by *edges* in various irregular ways. Yet most machine learning (ML) algorithms allow only for regular and uniform relations between input objects, such as a grid of pixels, a sequence of words, or no relation at all.
Graph neural networks, or GNNs for short, have emerged as a powerful technique to leverage both the graph’s connectivity (as in the older algorithms DeepWalk and Node2Vec) and the input features on the various nodes and edges. GNNs can make predictions for graphs as a whole (Does this molecule react in a certain way?), for individual nodes (What’s the topic of this document, given its citations?) or for potential edges (Is this product likely to be purchased together with that product?). Apart from making predictions about graphs, GNNs are a powerful tool used to bridge the chasm to more typical neural network use cases. They encode a graph's *discrete*, *relational* information in a *continuous* way so that it can be included naturally in another deep learning system.
We are excited to announce the release of TensorFlow GNN 1.0 (TF-GNN), a production-tested library for building GNNs at large scales. It supports both modeling and training in TensorFlow as well as the extraction of input graphs from huge data stores. TF-GNN is built from the ground up for heterogeneous graphs, where types of objects and relations are represented by distinct sets of nodes and edges. Real-world objects and their relations occur in distinct types, and TF-GNN's heterogeneous focus makes it natural to represent them.
Inside TensorFlow, such graphs are represented by objects of type tfgnn.GraphTensor. This is a composite tensor type (a collection of tensors in one Python class) accepted as a first-class citizen in tf.data.Dataset, tf.function, etc. It stores both the graph structure and its features attached to nodes, edges and the graph as a whole. Trainable transformations of GraphTensors can be defined as Layers objects in the high-level Keras API, or directly using the tfgnn.GraphTensor primitive.
**
GNNs: Making predictions for an object in context
For illustration, let’s look at one typical application of TF-GNN: predicting a property of a certain type of node in a graph defined by cross-referencing tables of a huge database. For example, a citation database of Computer Science (CS) arXiv papers with one-to-many cites and many-to-one cited relationships where we would like to predict the subject area of each paper.
Like most neural networks, a GNN is trained on a dataset of many labeled examples (~millions), but each training step consists only of a much smaller batch of training examples (say, hundreds). To scale to millions, the GNN gets trained on a stream of reasonably small subgraphs from the underlying graph. Each subgraph contains enough of the original data to compute the GNN result for the labeled node at its center and train the model. This process — typically referred to as subgraph sampling — is extremely consequential for GNN training. Most existing tooling accomplishes sampling in a batch way, producing static subgraphs for training. TF-GNN provides tooling to improve on this by sampling dynamically and interactively.
Pictured, the process of subgraph sampling where small, tractable subgraphs are sampled from a larger graph to create input examples for GNN training.
TF-GNN 1.0 debuts a flexible Python API to configure dynamic or batch subgraph sampling at all relevant scales: interactively in a Colab notebook (like this one), for efficient sampling of a small dataset stored in the main memory of a single training host, or distributed by Apache Beam for huge datasets stored on a network filesystem (up to hundreds of millions of nodes and billions of edges). For details, please refer to our user guides for in-memory and beam-based sampling, respectively.
On those same sampled subgraphs, the GNN’s task is to compute a hidden (or latent) state at the root node; the hidden state aggregates and encodes the relevant information of the root node's neighborhood. One classical approach is message-passing neural networks. In each round of message passing, nodes receive messages from their neighbors along incoming edges and update their own hidden state from them. After *n* rounds, the hidden state of the root node reflects the aggregate information from all nodes within *n* edges (pictured below for *n* = 2). The messages and the new hidden states are computed by hidden layers of the neural network. In a heterogeneous graph, it often makes sense to use separately trained hidden layers for the different types of nodes and edges
Pictured, a simple message-passing neural network where, at each step, the node state is propagated from outer to inner nodes where it is pooled to compute new node states. Once the root node is reached, a final prediction can be made.
The training setup is completed by placing an output layer on top of the GNN’s hidden state for the labeled nodes, computing the *loss *(to measure the prediction error), and updating model weights by backpropagation, as usual in any neural network training.
Beyond supervised training (i.e., minimizing a loss defined by labels), GNNs can also be trained in an unsupervised way (i.e., without labels). This lets us compute a *continuous* representation (or *embedding*) of the *discrete* graph structure of nodes and their features. These representations are then typically utilized in other ML systems. In this way, the discrete, relational information encoded by a graph can be included in more typical neural network use cases. TF-GNN supports a fine-grained specification of unsupervised objectives for heterogeneous graphs.
Building GNN architectures
The TF-GNN library supports building and training GNNs at various levels of abstraction.
At the highest level, users can take any of the predefined models bundled with the library that are expressed in Keras layers. Besides a small collection of models from the research literature, TF-GNN comes with a highly configurable model template that provides a curated selection of modeling choices that we have found to provide strong baselines on many of our in-house problems. The templates implement GNN layers; users need only to initialize the Keras layers.
At the lowest level, users can write a GNN model from scratch in terms of primitives for passing data around the graph, such as broadcasting data from a node to all its outgoing edges or pooling data into a node from all its incoming edges (e.g., computing the sum of incoming messages). TF-GNN’s graph data model treats nodes, edges and whole input graphs equally when it comes to features or hidden states, making it straightforward to express not only node-centric models like the MPNN discussed above but also more general forms of GraphNets. This can, but need not, be done with Keras as a modeling framework on the top of core TensorFlow. For more details, and intermediate levels of modeling, see the TF-GNN user guide and model collection.
Training orchestration
While advanced users are free to do custom model training, the TF-GNN Runner also provides a succinct way to orchestrate the training of Keras models in the common cases. A simple invocation may look like this:
The Runner provides ready-to-use solutions for ML pains like distributed training and tfgnn.GraphTensor padding for fixed shapes on Cloud TPUs. Beyond training on a single task (as shown above), it supports joint training on multiple (two or more) tasks in concert. For example, unsupervised tasks can be mixed with supervised ones to inform a final continuous representation (or embedding) with application specific inductive biases. Callers only need substitute the task argument with a mapping of tasks:
Additionally, the TF-GNN Runner also includes an implementation of integrated gradients for use in model attribution. Integrated gradients output is a GraphTensor with the same connectivity as the observed GraphTensor but its features replaced with gradient values where larger values contribute more than smaller values in the GNN prediction. Users can inspect gradient values to see which features their GNN uses the most.
Conclusion
In short, we hope TF-GNN will be useful to advance the application of GNNs in TensorFlow at scale and fuel further innovation in the field. If you’re curious to find out more, please try our Colab demo with the popular OGBN-MAG benchmark (in your browser, no installation required), browse the rest of our user guides and Colabs, or take a look at our paper.
Acknowledgements
*The TF-GNN release 1.0 was developed by a collaboration between Google Research: Sami Abu-El-Haija, Neslihan Bulut, Bahar Fatemi, Johannes Gasteiger, Pedro Gonnet, Jonathan Halcrow, Liangze Jiang, Silvio Lattanzi, Brandon Mayer, Vahab Mirrokni, Bryan Perozzi, Anton Tsitsulin, Dustin Zelle, Google Core ML: Arno Eigenwillig, Oleksandr Ferludin, Parth Kothari, Mihir Paradkar, Jan Pfeifer, Rachael Tamakloe, and Google DeepMind: **Alvaro Sanchez-Gonzalez and Lisa Wang.*
関連記事
今日のまとめ
AI日報で今日の重要ニュースをまとめ読み