77 "provenance": [],
88 "collapsed_sections": [],
99 "machine_shape": "hm",
10- "authorship_tag": "ABX9TyNA3ll3uX2gKSYAufoNcN5Q "
10+ "authorship_tag": "ABX9TyOg+5is5uvaVkxpERB+P/YF "
1111 },
1212 "kernelspec": {
1313 "name": "python3",
132132 "cell_type": "code",
133133 "metadata": {
134134 "id": "uVnjPmOaQlnH",
135- "outputId": "5c4dee17-ba2e-4e81-d42b-feae4f19c929",
136135 "colab": {
137136 "base_uri": "https://localhost:8080/"
138- }
137+ },
138+ "outputId": "5c4dee17-ba2e-4e81-d42b-feae4f19c929"
139139 },
140140 "source": [
141141 "!pip install --quiet neural-structured-learning\n",
166166 "cell_type": "code",
167167 "metadata": {
168168 "id": "OpLo-U08i3PX",
169- "outputId": "871b49f1-6349-4acb-baa0-02db4300caa2",
170169 "colab": {
171170 "base_uri": "https://localhost:8080/"
172- }
171+ },
172+ "outputId": "871b49f1-6349-4acb-baa0-02db4300caa2"
173173 },
174174 "source": [
175175 "from sklearn.random_projection import gaussian_random_matrix\n",
230230 "cell_type": "code",
231231 "metadata": {
232232 "id": "ntzN4Am1i5-U",
233- "outputId": "4d0d8e41-5cf9-4d88-f7dc-b6de79e61e38",
234233 "colab": {
235234 "base_uri": "https://localhost:8080/"
236- }
235+ },
236+ "outputId": "4d0d8e41-5cf9-4d88-f7dc-b6de79e61e38"
237237 },
238238 "source": [
239239 "train_ds, validation_ds = tfds.load(\n",
284284 "cell_type": "code",
285285 "metadata": {
286286 "id": "K7ZHPYrBjjYl",
287- "outputId": "1e6bb915-0ac5-4f68-be6e-96dadc11f89b",
288287 "colab": {
289288 "base_uri": "https://localhost:8080/",
290289 "height": 572
291- }
290+ },
291+ "outputId": "1e6bb915-0ac5-4f68-be6e-96dadc11f89b"
292292 },
293293 "source": [
294294 "plt.figure(figsize=(10, 10))\n",
327327 "cell_type": "code",
328328 "metadata": {
329329 "id": "WsPVr-3WjrUi",
330- "outputId": "7e2cd39c-193a-474a-f7e9-3fbbb5832334",
331330 "colab": {
332331 "base_uri": "https://localhost:8080/"
333- }
332+ },
333+ "outputId": "7e2cd39c-193a-474a-f7e9-3fbbb5832334"
334334 },
335335 "source": [
336336 "num_train_examples = tf.data.experimental.cardinality(train_ds)\n",
433433 "cell_type": "code",
434434 "metadata": {
435435 "id": "f_-XRns3maF5",
436- "outputId": "85676659-5a3c-4b5e-facf-5bb28dfc6795",
437436 "colab": {
438437 "base_uri": "https://localhost:8080/"
439- }
438+ },
439+ "outputId": "85676659-5a3c-4b5e-facf-5bb28dfc6795"
440440 },
441441 "source": [
442442 "feature_extractor = create_feature_extractor_model()\n",
505505 "cell_type": "code",
506506 "metadata": {
507507 "id": "FAIhVW6InktB",
508- "outputId": "80093f18-24cd-4245-a3d5-fcc942dc4ab3",
509508 "colab": {
510509 "base_uri": "https://localhost:8080/"
511- }
510+ },
511+ "outputId": "80093f18-24cd-4245-a3d5-fcc942dc4ab3"
512512 },
513513 "source": [
514514 "def _int64_feature(value):\n",
650650 "cell_type": "code",
651651 "metadata": {
652652 "id": "ob9GwDWOy4vt",
653- "outputId": "a6c4b80d-de1a-4175-a2da-c83b1bff08f4",
654653 "colab": {
655654 "base_uri": "https://localhost:8080/"
656- }
655+ },
656+ "outputId": "a6c4b80d-de1a-4175-a2da-c83b1bff08f4"
657657 },
658658 "source": [
659659 "!wc -l flowers_graph_70.tsv"
798798 "cell_type": "code",
799799 "metadata": {
800800 "id": "dZeyYg1Rvg8W",
801- "outputId": "a6b1664a-b3cd-4a60-84d4-85c10cf200ee",
802801 "colab": {
803802 "base_uri": "https://localhost:8080/"
804- }
803+ },
804+ "outputId": "a6b1664a-b3cd-4a60-84d4-85c10cf200ee"
805805 },
806806 "source": [
807807 "!ls -lh *_data.tfr"
10441044 "cell_type": "code",
10451045 "metadata": {
10461046 "id": "Z4mGjVLw3jNc",
1047- "outputId": "0fa10c24-9ed2-4b5b-e13d-1ec3f75f5187",
10481047 "colab": {
10491048 "base_uri": "https://localhost:8080/"
1050- }
1049+ },
1050+ "outputId": "0fa10c24-9ed2-4b5b-e13d-1ec3f75f5187"
10511051 },
10521052 "source": [
10531053 "def make_cnn_model():\n",
11261126 "cell_type": "code",
11271127 "metadata": {
11281128 "id": "gSUYa1UL5rA4",
1129- "outputId": "0c670fd7-7349-4963-eaa7-51328c7ee49d",
11301129 "colab": {
11311130 "base_uri": "https://localhost:8080/"
1132- }
1131+ },
1132+ "outputId": "0c670fd7-7349-4963-eaa7-51328c7ee49d"
11331133 },
11341134 "source": [
11351135 "history = model.fit(\n",
12351235 "cell_type": "code",
12361236 "metadata": {
12371237 "id": "E9CXstqo5zjW",
1238- "outputId": "03dc1dbb-a5af-4261-d616-97b89a379808",
12391238 "colab": {
12401239 "base_uri": "https://localhost:8080/",
12411240 "height": 295
1242- }
1241+ },
1242+ "outputId": "03dc1dbb-a5af-4261-d616-97b89a379808"
12431243 },
12441244 "source": [
12451245 "history_dict = history.history\n",
12821282 "cell_type": "code",
12831283 "metadata": {
12841284 "id": "8zl_bCYy68lT",
1285- "outputId": "7e0616c9-b5a0-4a2e-bf79-702af9b5576e",
12861285 "colab": {
12871286 "base_uri": "https://localhost:8080/",
12881287 "height": 295
1289- }
1288+ },
1289+ "outputId": "7e0616c9-b5a0-4a2e-bf79-702af9b5576e"
12901290 },
12911291 "source": [
12921292 "plt.clf() # clear figure\n",
13911391 "cell_type": "code",
13921392 "metadata": {
13931393 "id": "RLRxxV4G7McQ",
1394- "outputId": "1a8ea43f-6af0-4249-f070-12a7d11f8947",
13951394 "colab": {
13961395 "base_uri": "https://localhost:8080/"
1397- }
1396+ },
1397+ "outputId": "1a8ea43f-6af0-4249-f070-12a7d11f8947"
13981398 },
13991399 "source": [
14001400 "graph_reg_history = graph_reg_model.fit(\n",
15001500 "cell_type": "code",
15011501 "metadata": {
15021502 "id": "84ffIFmd7PMz",
1503- "outputId": "2a497a35-633d-43bd-b196-a6012dfa5d52",
15041503 "colab": {
15051504 "base_uri": "https://localhost:8080/",
15061505 "height": 295
1507- }
1506+ },
1507+ "outputId": "2a497a35-633d-43bd-b196-a6012dfa5d52"
15081508 },
15091509 "source": [
15101510 "graph_reg_history_dict = graph_reg_history.history\n",
15521552 "cell_type": "code",
15531553 "metadata": {
15541554 "id": "5EJUJJja7lEB",
1555- "outputId": "36594560-1a09-4225-b662-3df3d59755b0",
15561555 "colab": {
15571556 "base_uri": "https://localhost:8080/",
15581557 "height": 295
1559- }
1558+ },
1559+ "outputId": "36594560-1a09-4225-b662-3df3d59755b0"
15601560 },
15611561 "source": [
15621562 "plt.clf() # clear figure\n",
16191619 "cell_type": "code",
16201620 "metadata": {
16211621 "id": "2QeTI1q98YOR",
1622- "outputId": "764ec1ec-f279-4437-b3b9-4ddba2582c12",
16231622 "colab": {
16241623 "base_uri": "https://localhost:8080/"
1625- }
1624+ },
1625+ "outputId": "764ec1ec-f279-4437-b3b9-4ddba2582c12"
16261626 },
16271627 "source": [
16281628 "sample = next(iter(train_dataset))\n",
16461646 "cell_type": "code",
16471647 "metadata": {
16481648 "id": "k2M-OUoH83KQ",
1649- "outputId": "d01dac92-0c9c-470f-db42-bdab1fca300e",
16501649 "colab": {
16511650 "base_uri": "https://localhost:8080/",
16521651 "height": 376
1653- }
1652+ },
1653+ "outputId": "d01dac92-0c9c-470f-db42-bdab1fca300e"
16541654 },
16551655 "source": [
16561656 "plt.figure(figsize=(20, 20))\n",
17141714 "users to experiment further by varying hyperparameters, the amount of\n",
17151715 "supervision, and by using different model architectures."
17161716 ]
1717+ },
1718+ {
1719+ "cell_type": "markdown",
1720+ "metadata": {
1721+ "id": "AV6RysJlm-D0"
1722+ },
1723+ "source": [
1724+ "## Acknowledgements\n",
1725+ "\n",
1726+ "Thanks to [Arjun Gopalan](https://research.google/people/ArjunGopalan/) from Google. Without his guidance, this tutorial would have been possible."
1727+ ]
17171728 }
17181729 ]
17191730}
0 commit comments