|
47 | 47 | "id": "ev9vJpM94c3i" |
48 | 48 | }, |
49 | 49 | "source": [ |
50 | | - "\u003ctable class=\"tfo-notebook-buttons\" align=\"left\"\u003e\n", |
51 | | - " \u003ctd\u003e\n", |
52 | | - " \u003ctd\u003e\n", |
53 | | - " \u003ca target=\"_blank\" href=\"https://colab.research.google.com/github/tensorflow/gnn/blob/master/examples/notebooks/ogbn_mag_indepth.ipynb\"\u003e\u003cimg src=\"https://www.tensorflow.org/images/colab_logo_32px.png\" /\u003eRun in Google Colab\u003c/a\u003e\n", |
54 | | - " \u003c/td\u003e\n", |
55 | | - " \u003ctd\u003e\n", |
56 | | - " \u003ca target=\"_blank\" href=\"https://github.com/tensorflow/gnn/blob/main/examples/notebooks/ogbn_mag_indepth.ipynb\"\u003e\u003cimg src=\"https://www.tensorflow.org/images/GitHub-Mark-32px.png\" /\u003eView on GitHub\u003c/a\u003e\n", |
57 | | - " \u003c/td\u003e\n", |
58 | | - "\u003c/table\u003e" |
| 50 | + "<table class=\"tfo-notebook-buttons\" align=\"left\">\n", |
| 51 | + " <td>\n", |
| 52 | + " <td>\n", |
| 53 | + " <a target=\"_blank\" href=\"https://colab.research.google.com/github/tensorflow/gnn/blob/master/examples/notebooks/ogbn_mag_indepth.ipynb\"><img src=\"https://www.tensorflow.org/images/colab_logo_32px.png\" />Run in Google Colab</a>\n", |
| 54 | + " </td>\n", |
| 55 | + " <td>\n", |
| 56 | + " <a target=\"_blank\" href=\"https://github.com/tensorflow/gnn/blob/main/examples/notebooks/ogbn_mag_indepth.ipynb\"><img src=\"https://www.tensorflow.org/images/GitHub-Mark-32px.png\" />View on GitHub</a>\n", |
| 57 | + " </td>\n", |
| 58 | + "</table>" |
59 | 59 | ] |
60 | 60 | }, |
61 | 61 | { |
|
154 | 154 | "\n", |
155 | 155 | "OGBN-MAG is [Open Graph Benchmark](https://ogb.stanford.edu)'s Node classification task on a subset of the [Microsoft Academic Graph](https://www.microsoft.com/en-us/research/publication/microsoft-academic-graph-when-experts-are-not-enough/). The [basic tutorial](https://colab.research.google.com/github/tensorflow/gnn/blob/master/examples/notebooks/ogbn_mag_e2e.ipynb) has explained the dataset and the task in detail. To recap, the OGBN-MAG dataset is one big graph with node sets \"paper\", \"field_of_study\", \"author\", and \"institution\" and edge sets \"cites\", \"has_topic\", \"writes\", and \"affiliated_with\", each connecting two particular node sets.\n", |
156 | 156 | "\n", |
157 | | - "The task is to **predict the venue** (journal or conference, not represented in the graph itself) at which each of the papers has been published. Based on their \"year\" feature, the \"paper\" nodes are split into \"train\" (`year\u003c=2017`), \"validation\" (`year==2018`), and \"test\"(`year==2019`).\n" |
| 157 | + "The task is to **predict the venue** (journal or conference, not represented in the graph itself) at which each of the papers has been published. Based on their \"year\" feature, the \"paper\" nodes are split into \"train\" (`year<=2017`), \"validation\" (`year==2018`), and \"test\"(`year==2019`).\n" |
158 | 158 | ] |
159 | 159 | }, |
160 | 160 | { |
|
447 | 447 | " # For gs://download.tensorflow.org, we avoid listing it and do\n", |
448 | 448 | " filenames = _glob_sharded(file_pattern)\n", |
449 | 449 | " ds = tf.data.Dataset.from_tensor_slices(filenames)\n", |
450 | | - " if input_context and input_context.num_input_pipelines \u003e 1:\n", |
| 450 | + " if input_context and input_context.num_input_pipelines > 1:\n", |
451 | 451 | " ds = ds.shard(input_context.num_input_pipelines,\n", |
452 | 452 | " input_context.input_pipeline_id)\n", |
453 | 453 | " if shuffle:\n", |
|
680 | 680 | " years = tf.io.parse_single_example(serialized_example, features)[\"years\"]\n", |
681 | 681 | " year = years[0] # By convention, the root node is the first node.\n", |
682 | 682 | " if split_name == \"train\": # 629,571\n", |
683 | | - " return year \u003c= 2017\n", |
| 683 | + " return year <= 2017\n", |
684 | 684 | " elif split_name == \"validation\": # 64,879\n", |
685 | 685 | " return year == 2018\n", |
686 | 686 | " elif split_name == \"test\": # 41,939\n", |
|
762 | 762 | { |
763 | 763 | "data": { |
764 | 764 | "text/plain": [ |
765 | | - "\u003ctf.Tensor: shape=(30, 1), dtype=int64, numpy=\n", |
| 765 | + "<tf.Tensor: shape=(30, 1), dtype=int64, numpy=\n", |
766 | 766 | "array([[193],\n", |
767 | 767 | " [265],\n", |
768 | 768 | " [ 56],\n", |
|
792 | 792 | " [236],\n", |
793 | 793 | " [265],\n", |
794 | 794 | " [193],\n", |
795 | | - " [277]])\u003e" |
| 795 | + " [277]])>" |
796 | 796 | ] |
797 | 797 | }, |
798 | 798 | "execution_count": 11, |
|
847 | 847 | "name": "stdout", |
848 | 848 | "output_type": "stream", |
849 | 849 | "text": [ |
850 | | - "\u003ctf.RaggedTensor [[0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],\n", |
851 | | - " [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]]\u003e\n", |
852 | | - "\u003ctf.RaggedTensor [[20],\n", |
| 850 | + "<tf.RaggedTensor [[0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],\n", |
| 851 | + " [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]]>\n", |
| 852 | + "<tf.RaggedTensor [[20],\n", |
853 | 853 | " [11, 90, 144, 167, 181, 196, 199, 201, 228, 264, 267, 287, 376, 401],\n", |
854 | 854 | " [32, 88, 111, 175, 211, 235, 301, 309, 311, 350, 377, 521, 631, 688, 693,\n", |
855 | | - " 723, 760, 770, 788, 795, 940, 1100, 1127] ]\u003e\n" |
| 855 | + " 723, 760, 770, 788, 795, 940, 1100, 1127] ]>\n" |
856 | 856 | ] |
857 | 857 | } |
858 | 858 | ], |
|
1355 | 1355 | "name": "stderr", |
1356 | 1356 | "output_type": "stream", |
1357 | 1357 | "text": [ |
1358 | | - "WARNING:tensorflow:Mapping types may not work well with tf.nest. Prefer using MutableMapping for \u003cclass 'tensorflow_gnn.graph.graph_tensor._ImmutableMapping'\u003e\n", |
1359 | | - "WARNING:tensorflow:Mapping types may not work well with tf.nest. Prefer using MutableMapping for \u003cclass 'tensorflow_gnn.graph.graph_tensor._ImmutableMapping'\u003e\n" |
| 1358 | + "WARNING:tensorflow:Mapping types may not work well with tf.nest. Prefer using MutableMapping for <class 'tensorflow_gnn.graph.graph_tensor._ImmutableMapping'>\n", |
| 1359 | + "WARNING:tensorflow:Mapping types may not work well with tf.nest. Prefer using MutableMapping for <class 'tensorflow_gnn.graph.graph_tensor._ImmutableMapping'>\n" |
1360 | 1360 | ] |
1361 | 1361 | } |
1362 | 1362 | ], |
|
1563 | 1563 | "\n", |
1564 | 1564 | "Notice that the conventional names *source* and *target* for the endpoints of a directed edge do **not** prescribe the direction of information flow: each \"written\" edge logically goes from a paper to its author (so the \"author\" node is its `TARGET`), yet this model lets the data flow towards the paper (and the \"paper\" node is its `SOURCE`). In fact, sampled subgraphs have edges directed away from the root node, so data flow towards the root often goes from `TARGET` to `SOURCE`.\n", |
1565 | 1565 | "\n", |
1566 | | - "\u003e Note on terminology: Convolutions are best known in deep learning for convolutional neural networks on image data, in which they aggregate information from a small, fixed, implicitly understood neighborhood of each element in a pixel grid. The term loosely carries over to graphs by interpreting edges as explicit, variable definitions of a node's neighborhood.\n", |
| 1566 | + "> Note on terminology: Convolutions are best known in deep learning for convolutional neural networks on image data, in which they aggregate information from a small, fixed, implicitly understood neighborhood of each element in a pixel grid. The term loosely carries over to graphs by interpreting edges as explicit, variable definitions of a node's neighborhood.\n", |
1567 | 1567 | "\n", |
1568 | 1568 | "The code above creates fresh Convolution and NextState layer objects for each edge set and node set, resp., and for each round of updates. This means they all have separate trainable weights. If desired, weight sharing is possible in the standard Keras way by sharing convolution and next-state layer objects, provided the input sizes match.\n", |
1569 | 1569 | "\n", |
|
0 commit comments