├── README.md ├── develop ├── index.ipynb └── pipeline.ipynb ├── examples ├── code.ipynb ├── index.ipynb └── markdown.ipynb ├── img ├── build.svg ├── catdog.jpg ├── koebel.jpg └── lstm.svg ├── index.ipynb └── refs.bib /README.md: -------------------------------------------------------------------------------- 1 | # Colab notebooks for d2l-book 2 | 3 | Automatically generated notebooks for d2l-book. Don't edit directly. 4 | 5 | -------------------------------------------------------------------------------- /develop/index.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "metadata": {}, 6 | "source": [ 7 | "# Development\n", 8 | "\n", 9 | "Explain how it works." 10 | ] 11 | }, 12 | { 13 | "cell_type": "markdown", 14 | "metadata": {}, 15 | "source": [ 16 | "```toc\n", 17 | "pipeline\n", 18 | "```\n" 19 | ] 20 | } 21 | ], 22 | "metadata": { 23 | "kernelspec": { 24 | "display_name": "Python 3", 25 | "name": "python3" 26 | }, 27 | "language_info": { 28 | "name": "python" 29 | } 30 | }, 31 | "nbformat": 4, 32 | "nbformat_minor": 2 33 | } -------------------------------------------------------------------------------- /develop/pipeline.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "metadata": {}, 6 | "source": [ 7 | "# Build pipeline\n", 8 | "\n", 9 | "\n", 10 | "![](http://book.d2l.ai/_images/build.svg)\n", 11 | "\n", 12 | "The source files are markdown files. They are either purely markdown files or\n", 13 | "juypyter notebooks saved in the markdown format with output removed. For the\n", 14 | "latter, we may use Jupyter to edit them directly with the `notedown` plugin and\n", 15 | "then run \"Kernel -> Restart & Clear Output\" before committing.\n", 16 | "\n", 17 | "Then our building pipeline runs the following steps to publish the artifacts.\n", 18 | "\n", 19 | "1. Convert .md files into .ipynb files and evaluate each of them. The reason that\n", 20 | " we use .md file as source format is because it's easy to review the source\n", 21 | " changes. We evaluate every time to guarantee every notebook is\n", 22 | " executable. This evaluation step may be time consuming, we can\n", 23 | "\n", 24 | " - Assume every notebook can be executed in 10 minutes, we may use multiple\n", 25 | " GPUs to accelerate the execution\n", 26 | " - If the source .md file hasn't change since last evaluation, we can reuse\n", 27 | " the cached .ipynb file to avoid execution again.\n", 28 | " - We use multiple processes to run notebooks in parallel.\n", 29 | "\n", 30 | "1. The .ipynb files with outputs can be uploaded to Github directly so users can\n", 31 | " clone it to run them locally or on the cloud. Also we zip all files so users\n", 32 | " can download it easily\n", 33 | "\n", 34 | "1. These .ipynb files are then converted to .rst files with format compatible to\n", 35 | " Sphinx. Additional preprocessing steps are used for image/table/citation\n", 36 | " references.\n", 37 | "\n", 38 | "1. Use Sphinx to build .html and .pdf files\n", 39 | "\n", 40 | "1. Publish all .html/.pdf/.zip files online, such as into an AWS S3 bucket." 41 | ] 42 | } 43 | ], 44 | "metadata": { 45 | "kernelspec": { 46 | "display_name": "Python 3", 47 | "name": "python3" 48 | }, 49 | "language_info": { 50 | "name": "python" 51 | } 52 | }, 53 | "nbformat": 4, 54 | "nbformat_minor": 2 55 | } -------------------------------------------------------------------------------- /examples/code.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "metadata": {}, 6 | "source": [ 7 | "# Code Cells\n", 8 | "\n", 9 | ":label:`sec_code`" 10 | ] 11 | }, 12 | { 13 | "cell_type": "code", 14 | "execution_count": 1, 15 | "metadata": {}, 16 | "outputs": [ 17 | { 18 | "data": { 19 | "text/plain": [ 20 | "3" 21 | ] 22 | }, 23 | "execution_count": 1, 24 | "metadata": {}, 25 | "output_type": "execute_result" 26 | } 27 | ], 28 | "source": [ 29 | "\n", 30 | "1+2" 31 | ] 32 | }, 33 | { 34 | "cell_type": "code", 35 | "execution_count": 2, 36 | "metadata": {}, 37 | "outputs": [], 38 | "source": [ 39 | "!ls ." 40 | ] 41 | }, 42 | { 43 | "cell_type": "code", 44 | "execution_count": 3, 45 | "metadata": {}, 46 | "outputs": [ 47 | { 48 | "data": { 49 | "text/plain": [ 50 | "'A code line with 78 chars should not be wrappered =========================='" 51 | ] 52 | }, 53 | "execution_count": 3, 54 | "metadata": {}, 55 | "output_type": "execute_result" 56 | } 57 | ], 58 | "source": [ 59 | "'A code line with 78 chars should not be wrappered =========================='" 60 | ] 61 | }, 62 | { 63 | "cell_type": "markdown", 64 | "metadata": {}, 65 | "source": [ 66 | "## Hide Source and Outputs\n", 67 | "\n", 68 | "We can hide the source of a code cell by adding a comment line `# Hide\n", 69 | "code` in the cell. We can also hide the code cell outputs using `# Hide outputs`\n", 70 | "\n", 71 | "For example, here is the normal code cell:" 72 | ] 73 | }, 74 | { 75 | "cell_type": "code", 76 | "execution_count": 4, 77 | "metadata": {}, 78 | "outputs": [ 79 | { 80 | "data": { 81 | "text/plain": [ 82 | "6" 83 | ] 84 | }, 85 | "execution_count": 4, 86 | "metadata": {}, 87 | "output_type": "execute_result" 88 | } 89 | ], 90 | "source": [ 91 | "1+2+3" 92 | ] 93 | }, 94 | { 95 | "cell_type": "markdown", 96 | "metadata": {}, 97 | "source": [ 98 | "Let's hide the source codes" 99 | ] 100 | }, 101 | { 102 | "cell_type": "code", 103 | "execution_count": 5, 104 | "metadata": {}, 105 | "outputs": [ 106 | { 107 | "data": { 108 | "text/plain": [ 109 | "6" 110 | ] 111 | }, 112 | "execution_count": 5, 113 | "metadata": {}, 114 | "output_type": "execute_result" 115 | } 116 | ], 117 | "source": [ 118 | "# Hide code\n", 119 | "1+2+3" 120 | ] 121 | }, 122 | { 123 | "cell_type": "markdown", 124 | "metadata": {}, 125 | "source": [ 126 | "Also try hiding the outputs" 127 | ] 128 | }, 129 | { 130 | "cell_type": "code", 131 | "execution_count": 6, 132 | "metadata": {}, 133 | "outputs": [ 134 | { 135 | "data": { 136 | "text/plain": [ 137 | "6" 138 | ] 139 | }, 140 | "execution_count": 6, 141 | "metadata": {}, 142 | "output_type": "execute_result" 143 | } 144 | ], 145 | "source": [ 146 | "# Hide outputs\n", 147 | "1+2+3" 148 | ] 149 | }, 150 | { 151 | "cell_type": "markdown", 152 | "metadata": {}, 153 | "source": [ 154 | "## Plot" 155 | ] 156 | }, 157 | { 158 | "cell_type": "code", 159 | "execution_count": 7, 160 | "metadata": { 161 | "attributes": { 162 | "classes": [], 163 | "id": "", 164 | "n": "3" 165 | } 166 | }, 167 | "outputs": [ 168 | { 169 | "data": { 170 | "image/svg+xml": [ 171 | "\n", 172 | "\n", 174 | "\n", 175 | "\n", 176 | " \n", 177 | " \n", 180 | " \n", 181 | " \n", 182 | " \n", 183 | " \n", 189 | " \n", 190 | " \n", 191 | " \n", 192 | " \n", 198 | " \n", 199 | " \n", 200 | " \n", 201 | " \n", 202 | " \n", 203 | " \n", 206 | " \n", 207 | " \n", 208 | " \n", 209 | " \n", 210 | " \n", 211 | " \n", 212 | " \n", 213 | " \n", 214 | " \n", 235 | " \n", 236 | " \n", 237 | " \n", 238 | " \n", 239 | " \n", 240 | " \n", 241 | " \n", 242 | " \n", 243 | " \n", 244 | " \n", 245 | " \n", 246 | " \n", 247 | " \n", 248 | " \n", 249 | " \n", 250 | " \n", 274 | " \n", 275 | " \n", 276 | " \n", 277 | " \n", 278 | " \n", 279 | " \n", 280 | " \n", 281 | " \n", 282 | " \n", 283 | " \n", 284 | " \n", 285 | " \n", 286 | " \n", 287 | " \n", 288 | " \n", 289 | " \n", 306 | " \n", 307 | " \n", 308 | " \n", 309 | " \n", 310 | " \n", 311 | " \n", 312 | " \n", 313 | " \n", 314 | " \n", 315 | " \n", 316 | " \n", 317 | " \n", 318 | " \n", 319 | " \n", 320 | " \n", 321 | " \n", 351 | " \n", 352 | " \n", 353 | " \n", 354 | " \n", 355 | " \n", 356 | " \n", 357 | " \n", 358 | " \n", 359 | " \n", 360 | " \n", 361 | " \n", 362 | " \n", 363 | " \n", 364 | " \n", 365 | " \n", 366 | " \n", 405 | " \n", 406 | " \n", 407 | " \n", 408 | " \n", 409 | " \n", 410 | " \n", 411 | " \n", 412 | " \n", 413 | " \n", 414 | " \n", 415 | " \n", 416 | " \n", 417 | " \n", 418 | " \n", 419 | " \n", 420 | " \n", 433 | " \n", 434 | " \n", 435 | " \n", 436 | " \n", 437 | " \n", 438 | " \n", 439 | " \n", 440 | " \n", 441 | " \n", 442 | " \n", 443 | " \n", 444 | " \n", 445 | " \n", 448 | " \n", 449 | " \n", 450 | " \n", 451 | " \n", 452 | " \n", 453 | " \n", 454 | " \n", 455 | " \n", 456 | " \n", 462 | " \n", 468 | " \n", 469 | " \n", 470 | " \n", 471 | " \n", 472 | " \n", 473 | " \n", 474 | " \n", 475 | " \n", 476 | " \n", 477 | " \n", 478 | " \n", 479 | " \n", 480 | " \n", 481 | " \n", 482 | " \n", 483 | " \n", 484 | " \n", 485 | " \n", 486 | " \n", 487 | " \n", 496 | " \n", 520 | " \n", 521 | " \n", 522 | " \n", 523 | " \n", 524 | " \n", 525 | " \n", 526 | " \n", 527 | " \n", 528 | " \n", 529 | " \n", 530 | " \n", 531 | " \n", 532 | " \n", 533 | " \n", 534 | " \n", 535 | " \n", 536 | " \n", 537 | " \n", 538 | " \n", 539 | " \n", 540 | " \n", 541 | " \n", 542 | " \n", 543 | " \n", 544 | " \n", 545 | " \n", 546 | " \n", 547 | " \n", 548 | " \n", 549 | " \n", 550 | " \n", 551 | " \n", 552 | " \n", 553 | " \n", 554 | " \n", 555 | " \n", 556 | " \n", 557 | " \n", 558 | " \n", 559 | " \n", 560 | " \n", 561 | " \n", 562 | " \n", 563 | " \n", 564 | " \n", 565 | " \n", 566 | " \n", 567 | " \n", 568 | " \n", 569 | " \n", 570 | " \n", 571 | " \n", 572 | " \n", 573 | " \n", 574 | " \n", 575 | " \n", 576 | " \n", 577 | " \n", 578 | " \n", 579 | " \n", 580 | " \n", 581 | " \n", 582 | " \n", 583 | " \n", 584 | " \n", 585 | " \n", 586 | " \n", 587 | " \n", 588 | " \n", 589 | " \n", 590 | " \n", 591 | " \n", 592 | " \n", 593 | " \n", 594 | " \n", 595 | " \n", 596 | " \n", 597 | " \n", 598 | " \n", 599 | " \n", 600 | " \n", 601 | " \n", 602 | " \n", 603 | " \n", 604 | " \n", 605 | " \n", 606 | " \n", 607 | " \n", 608 | " \n", 609 | " \n", 610 | " \n", 611 | " \n", 612 | " \n", 613 | " \n", 614 | " \n", 615 | " \n", 616 | " \n", 617 | " \n", 618 | " \n", 619 | " \n", 620 | " \n", 621 | " \n", 622 | " \n", 623 | " \n", 624 | " \n", 625 | " \n", 626 | " \n", 627 | " \n", 628 | " \n", 629 | " \n", 630 | " \n", 631 | " \n", 632 | " \n", 633 | " \n", 634 | " \n", 635 | " \n", 636 | " \n", 637 | " \n", 638 | " \n", 639 | " \n", 640 | " \n", 641 | " \n", 642 | " \n", 643 | " \n", 644 | " \n", 645 | " \n", 646 | " \n", 747 | " \n", 748 | " \n", 749 | " \n", 752 | " \n", 753 | " \n", 754 | " \n", 757 | " \n", 758 | " \n", 759 | " \n", 762 | " \n", 763 | " \n", 764 | " \n", 767 | " \n", 768 | " \n", 769 | " \n", 770 | " \n", 771 | " \n", 772 | " \n", 773 | " \n", 774 | " \n", 775 | "\n" 776 | ], 777 | "text/plain": [ 778 | "
" 779 | ] 780 | }, 781 | "metadata": { 782 | "needs_background": "light" 783 | }, 784 | "output_type": "display_data" 785 | } 786 | ], 787 | "source": [ 788 | "%matplotlib inline\n", 789 | "from IPython import display\n", 790 | "from matplotlib import pyplot as plt\n", 791 | "import numpy as np\n", 792 | "\n", 793 | "display.set_matplotlib_formats('svg')\n", 794 | "\n", 795 | "x = np.arange(0, 10, 0.1)\n", 796 | "plt.plot(x, np.sin(x));" 797 | ] 798 | } 799 | ], 800 | "metadata": { 801 | "kernelspec": { 802 | "display_name": "Python 3", 803 | "name": "python3" 804 | }, 805 | "language_info": { 806 | "name": "python" 807 | } 808 | }, 809 | "nbformat": 4, 810 | "nbformat_minor": 2 811 | } -------------------------------------------------------------------------------- /examples/index.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "metadata": {}, 6 | "source": [ 7 | "# Examples\n", 8 | "\n", 9 | "Various examples" 10 | ] 11 | }, 12 | { 13 | "cell_type": "markdown", 14 | "metadata": {}, 15 | "source": [ 16 | "```toc\n", 17 | ":maxdepth: 2\n", 18 | "\n", 19 | "markdown\n", 20 | "code\n", 21 | "```\n" 22 | ] 23 | } 24 | ], 25 | "metadata": { 26 | "kernelspec": { 27 | "display_name": "Python 3", 28 | "name": "python3" 29 | }, 30 | "language_info": { 31 | "name": "python" 32 | } 33 | }, 34 | "nbformat": 4, 35 | "nbformat_minor": 2 36 | } -------------------------------------------------------------------------------- /examples/markdown.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "metadata": {}, 6 | "source": [ 7 | "# Markdown Cells\n", 8 | "\n", 9 | "The `d2lbook` provide additional features beyond the normal markdown supports in\n", 10 | "Jupyter.\n", 11 | "\n", 12 | "## Table of Contents\n", 13 | "\n", 14 | "You can use a `toc` code block to specify the table of contents.\n", 15 | "Here `:maxdepth: 2` means display two levels of files, and `:numbered:` means\n", 16 | "adding number to each section (default is not enabled). Also note that you don't\n", 17 | "need to specify the file extension." 18 | ] 19 | }, 20 | { 21 | "cell_type": "markdown", 22 | "metadata": {}, 23 | "source": [ 24 | "`````\n", 25 | "```toc\n", 26 | ":maxdepth: 2\n", 27 | ":numbered:\n", 28 | "\n", 29 | "guide/index\n", 30 | "```\n", 31 | "`````\n" 32 | ] 33 | }, 34 | { 35 | "cell_type": "markdown", 36 | "metadata": {}, 37 | "source": [ 38 | "## Images\n", 39 | "\n", 40 | "\n", 41 | "We can put the image caption in `[]`. In addition, we can use\n", 42 | "`:width:` followed by its value in an inline block to specify the image width,\n", 43 | "similarly use `:height:`for height." 44 | ] 45 | }, 46 | { 47 | "cell_type": "markdown", 48 | "metadata": {}, 49 | "source": [ 50 | "```\n", 51 | "![Estimating the length of a foot](../img/koebel.jpg)\n", 52 | ":width:`400px`\n", 53 | "```\n" 54 | ] 55 | }, 56 | { 57 | "cell_type": "markdown", 58 | "metadata": {}, 59 | "source": [ 60 | "![Estimating the length of a foot](../img/koebel.jpg)\n", 61 | "\n", 62 | ":width:`400px`\n", 63 | "\n", 64 | "\n", 65 | "\n", 66 | "### SVG Images\n", 67 | "\n", 68 | "We recommend you to use SVG images as much as you can. It is sharp and its size\n", 69 | "is small. But since Latex doesn't support SVG images, if you want to build a PDF\n", 70 | "output, you need to install `rsvg-convert`. On Macos, you can simply\n", 71 | "`brew install librsvg` or `sudo apt-get install librsvg2-bin` for Ubuntu.\n", 72 | "\n", 73 | "![A LSTM cell in SVG](http://book.d2l.ai/_images/lstm.svg)\n", 74 | "\n", 75 | "## Tables\n", 76 | "\n", 77 | "You can insert table caption before the table by starting it with a `:`. Note\n", 78 | "that you need to leave an empty line between the caption and the table itself." 79 | ] 80 | }, 81 | { 82 | "cell_type": "markdown", 83 | "metadata": {}, 84 | "source": [ 85 | "```\n", 86 | ": The number is computed by $z_{ij} = \\sum_{k}x_{ik}y_{kj}$.\n", 87 | "\n", 88 | "| Year | Number | Comment |\n", 89 | "| --- | --- | --- |\n", 90 | "| 2018 | 100 | Good year |\n", 91 | "| 2019 | 200 | Even better, add something to make this column wider |\n", 92 | "```\n" 93 | ] 94 | }, 95 | { 96 | "cell_type": "markdown", 97 | "metadata": {}, 98 | "source": [ 99 | ": The number is computed by $z_{ij} = \\sum_{k}x_{ik}y_{kj}$.\n", 100 | "\n", 101 | "| Year | Number | Comment |\n", 102 | "| --- | --- | --- |\n", 103 | "| 2018 | 100 | Good year |\n", 104 | "| 2019 | 200 | Even better, add something to make this column wider |\n", 105 | "\n", 106 | "If the Table caption number doesn't show properly, you may need to update\n", 107 | "`pandoc` to the latest version.\n", 108 | "\n", 109 | "## Cross References\n", 110 | "\n", 111 | "We often want to reference sections, figures, tables and equations in a book.\n", 112 | "\n", 113 | "### Referencing Sections\n", 114 | "\n", 115 | ":label:`my_sec3`\n", 116 | "\n", 117 | "\n", 118 | "We can put a label immediately after the section title to allow this section to\n", 119 | "be referenced by its label. The label format is\n", 120 | "`:label:` followed by its label name in an inline code block." 121 | ] 122 | }, 123 | { 124 | "cell_type": "markdown", 125 | "metadata": {}, 126 | "source": [ 127 | "```\n", 128 | "### Referencing Sections\n", 129 | ":label:`my_sec3`\n", 130 | "```\n" 131 | ] 132 | }, 133 | { 134 | "cell_type": "markdown", 135 | "metadata": {}, 136 | "source": [ 137 | "Then we can reference this section through `:ref:` followed by label name in an\n", 138 | "inline code block" 139 | ] 140 | }, 141 | { 142 | "cell_type": "markdown", 143 | "metadata": {}, 144 | "source": [ 145 | "```\n", 146 | ":ref:`my_sec3` demonstrates how to reference a section.\n", 147 | "```\n" 148 | ] 149 | }, 150 | { 151 | "cell_type": "markdown", 152 | "metadata": {}, 153 | "source": [ 154 | ":ref:`my_sec3` demonstrates how to reference a section.\n", 155 | "\n", 156 | "\n", 157 | "Note that it displays the referenced section title with a clickable link. We can\n", 158 | "also use a numbered version by changing `:num:` to `:numref:`, e.g. :numref:`my_sec3`.\n", 159 | "\n", 160 | "If the label is incorrect, say we put `my_sec2` here, the build log will\n", 161 | "contains a warning such as" 162 | ] 163 | }, 164 | { 165 | "cell_type": "markdown", 166 | "metadata": {}, 167 | "source": [ 168 | "```\n", 169 | "WARNING: undefined label: my_sec2\n", 170 | "```\n" 171 | ] 172 | }, 173 | { 174 | "cell_type": "markdown", 175 | "metadata": {}, 176 | "source": [ 177 | "You can turn it into error by setting `warning_is_error = True` in\n", 178 | "`config.ini`.\n", 179 | "\n", 180 | "Besides, we can cross\n", 181 | "reference label from other files as well, e.g. :numref:`sec_code`. This applies\n", 182 | "to figures, tables and equations as well.\n", 183 | "\n", 184 | "\n", 185 | "### Referencing Images\n", 186 | "\n", 187 | "Similarly we can label an image and reference it later." 188 | ] 189 | }, 190 | { 191 | "cell_type": "markdown", 192 | "metadata": {}, 193 | "source": [ 194 | "```\n", 195 | "![A nice image with a cat and a dog.](../img/catdog.jpg)\n", 196 | ":width:`300px`\n", 197 | ":label:`img_catdog`\n", 198 | "\n", 199 | "As can be seen from :numref:`img_catdog`,\n", 200 | "```\n" 201 | ] 202 | }, 203 | { 204 | "cell_type": "markdown", 205 | "metadata": {}, 206 | "source": [ 207 | "![A nice image with a cat and a dog.](../img/catdog.jpg)\n", 208 | "\n", 209 | ":width:`300px`\n", 210 | "\n", 211 | "\n", 212 | ":label:`img_catdog`\n", 213 | "\n", 214 | "\n", 215 | "As can be seen from :numref:`img_catdog`, there is a cat and a dog.\n", 216 | "\n", 217 | "### Referencing Tables" 218 | ] 219 | }, 220 | { 221 | "cell_type": "markdown", 222 | "metadata": {}, 223 | "source": [ 224 | "```\n", 225 | ":This a is very long table caption. It will breaks into several lines. And\n", 226 | "contains a math equation as well. $z_{ij} = \\sum_{k}x_{ik}y_{kj}$.\n", 227 | "\n", 228 | "| Year | Number | Comment |\n", 229 | "| --- | --- | --- |\n", 230 | "| 2018 | 100 | Good year |\n", 231 | ":label:`table`\n", 232 | "\n", 233 | "Refer to :numref:`table`\n", 234 | "\n", 235 | "```\n" 236 | ] 237 | }, 238 | { 239 | "cell_type": "markdown", 240 | "metadata": {}, 241 | "source": [ 242 | ":This a is very long table caption. It will breaks into several lines. And\n", 243 | "contains a math equation as well. $z_{ij} = \\sum_{k}x_{ik}y_{kj}$.\n", 244 | "\n", 245 | "| Year | Number | Comment |\n", 246 | "| --- | --- | --- |\n", 247 | "| 2018 | 100 | Good year |\n", 248 | "\n", 249 | ":label:`table`\n", 250 | "\n", 251 | "\n", 252 | "Refer to :numref:`table`\n", 253 | "\n", 254 | "### Referencing Equations\n", 255 | "\n", 256 | "The difference here is that we need to use `eqlabel` instead of `label`. For\n", 257 | "example" 258 | ] 259 | }, 260 | { 261 | "cell_type": "markdown", 262 | "metadata": {}, 263 | "source": [ 264 | "```\n", 265 | "$$\\hat{\\mathbf{y}}=\\mathbf X \\mathbf{w}+b$$\n", 266 | ":eqlabel:`linear`\n", 267 | "\n", 268 | "\n", 269 | "In :eqref:`linear`, we define the linear model.\n", 270 | "```\n" 271 | ] 272 | }, 273 | { 274 | "cell_type": "markdown", 275 | "metadata": {}, 276 | "source": [ 277 | "$$\\hat{\\mathbf{y}}=\\mathbf X \\mathbf{w}+b$$\n", 278 | "\n", 279 | ":eqlabel:`linear`\n", 280 | "\n", 281 | "\n", 282 | "In :eqref:`linear`, we define the linear model.\n", 283 | "\n", 284 | "\n", 285 | "## Citations\n", 286 | "\n", 287 | "First put your bib file at somewhere. All references will be displayed on the\n", 288 | "place where it inserted in HTML. But in PDF, all references will be moved to end of\n", 289 | "the document. Then we can cite a paper through `:cite:`. Multipel papers can be\n", 290 | "separated by commans (note there should be no space)" 291 | ] 292 | }, 293 | { 294 | "cell_type": "markdown", 295 | "metadata": {}, 296 | "source": [ 297 | "```\n", 298 | "\n", 299 | "The breakthrough of deep learning origins from :cite:`krizhevsky2012imagenet` for...\n", 300 | "\n", 301 | "Two keys together :cite:`he2016deep,devlin2018bert`...\n", 302 | "\n", 303 | ":bibliography:`../refs.bib`\n", 304 | "```\n" 305 | ] 306 | }, 307 | { 308 | "cell_type": "markdown", 309 | "metadata": {}, 310 | "source": [ 311 | "The breakthrough of deep learning origins from :cite:`krizhevsky2012imagenet` for\n", 312 | "computer vision, there is a rich of following up works, such as\n", 313 | ":cite:`he2016deep`. NLP is catching up as well, the recent work\n", 314 | ":cite:`devlin2018bert` shows significant improvements.\n", 315 | "\n", 316 | "Two keys together :cite:`he2016deep,devlin2018bert`. Single author\n", 317 | ":cite:`mitchell80`, two authors :cite:`Newell81`\n", 318 | "\n", 319 | "## References\n", 320 | "\n", 321 | "\n", 322 | ":bibliography:`../refs.bib`" 323 | ] 324 | } 325 | ], 326 | "metadata": { 327 | "kernelspec": { 328 | "display_name": "Python 3", 329 | "name": "python3" 330 | }, 331 | "language_info": { 332 | "name": "python" 333 | } 334 | }, 335 | "nbformat": 4, 336 | "nbformat_minor": 2 337 | } -------------------------------------------------------------------------------- /img/build.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 | 167 | 168 | 169 | 170 | 171 | 172 | 173 | 174 | 175 | 176 | 177 | 178 | 179 | 180 | 181 | 182 | 183 | 184 | 185 | 186 | 187 | 188 | 189 | 190 | 191 | 192 | 193 | 194 | 195 | 196 | 197 | 198 | 199 | 200 | 201 | 202 | 203 | 204 | 205 | 206 | 207 | 208 | 209 | 210 | 211 | 212 | 213 | 214 | 215 | 216 | 217 | 218 | 219 | 220 | 221 | 222 | 223 | 224 | 225 | 226 | 227 | 228 | 229 | 230 | 231 | 232 | 233 | 234 | 235 | 236 | 237 | 238 | 239 | 240 | 241 | 242 | 243 | 244 | 245 | 246 | 247 | 248 | 249 | 250 | 251 | 252 | 253 | 254 | 255 | 256 | 257 | 258 | 259 | 260 | 261 | 262 | 263 | 264 | 265 | 266 | 267 | 268 | 269 | 270 | 271 | 272 | 273 | 274 | 275 | 276 | 277 | 278 | 279 | 280 | 281 | 282 | 283 | 284 | 285 | 286 | 287 | 288 | 289 | 290 | 291 | 292 | 293 | 294 | 295 | 296 | 297 | 298 | 299 | 300 | 301 | 302 | 303 | 304 | 305 | 306 | 307 | 308 | 309 | 310 | 311 | 312 | 313 | 314 | 315 | 316 | 317 | 318 | 319 | 320 | 321 | 322 | 323 | 324 | 325 | 326 | 327 | 328 | 329 | 330 | 331 | 332 | 333 | 334 | 335 | 336 | 337 | 338 | 339 | 340 | 341 | 342 | 343 | 344 | 345 | 346 | 347 | 348 | 349 | 350 | 351 | 352 | 353 | 354 | 355 | 356 | 357 | 358 | 359 | 360 | 361 | 362 | 363 | 364 | 365 | 366 | 367 | 368 | 369 | 370 | 371 | 372 | 373 | 374 | 375 | 376 | 377 | 378 | 379 | 380 | 381 | 382 | 383 | 384 | 385 | 386 | 387 | 388 | 389 | 390 | 391 | 392 | 393 | 394 | 395 | 396 | 397 | 398 | 399 | 400 | 401 | 402 | 403 | 404 | 405 | 406 | 407 | 408 | 409 | 410 | 411 | 412 | 413 | 414 | 415 | 416 | 417 | 418 | 419 | 420 | 421 | 422 | -------------------------------------------------------------------------------- /img/catdog.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/d2l-ai/d2l-book-colab/ee5251a48aeb3190648d9bb27f9eeff4415276bc/img/catdog.jpg -------------------------------------------------------------------------------- /img/koebel.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/d2l-ai/d2l-book-colab/ee5251a48aeb3190648d9bb27f9eeff4415276bc/img/koebel.jpg -------------------------------------------------------------------------------- /img/lstm.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 | 167 | 168 | 169 | 170 | 171 | 172 | 173 | 174 | 175 | 176 | 177 | 178 | 179 | 180 | 181 | 182 | 183 | 184 | 185 | 186 | 187 | 188 | 189 | 190 | 191 | 192 | 193 | 194 | 195 | 196 | 197 | 198 | 199 | 200 | 201 | 202 | 203 | 204 | 205 | 206 | 207 | 208 | 209 | 210 | 211 | 212 | 213 | 214 | 215 | 216 | 217 | 218 | 219 | 220 | 221 | 222 | 223 | 224 | 225 | 226 | 227 | 228 | 229 | 230 | 231 | 232 | 233 | 234 | 235 | 236 | 237 | 238 | 239 | 240 | 241 | 242 | 243 | 244 | 245 | 246 | 247 | 248 | 249 | 250 | 251 | 252 | 253 | 254 | 255 | 256 | 257 | 258 | 259 | 260 | 261 | 262 | 263 | 264 | 265 | 266 | 267 | 268 | 269 | 270 | 271 | 272 | 273 | 274 | 275 | 276 | 277 | 278 | 279 | 280 | 281 | 282 | 283 | 284 | 285 | 286 | 287 | 288 | 289 | 290 | 291 | 292 | 293 | 294 | 295 | 296 | 297 | 298 | 299 | 300 | 301 | 302 | 303 | 304 | 305 | 306 | 307 | 308 | 309 | 310 | 311 | 312 | 313 | 314 | 315 | 316 | 317 | 318 | 319 | 320 | 321 | 322 | 323 | 324 | 325 | 326 | 327 | 328 | 329 | 330 | 331 | 332 | 333 | 334 | 335 | 336 | 337 | 338 | 339 | 340 | 341 | 342 | 343 | 344 | 345 | 346 | 347 | 348 | 349 | 350 | 351 | 352 | 353 | 354 | 355 | 356 | 357 | 358 | 359 | 360 | 361 | 362 | 363 | 364 | 365 | 366 | 367 | 368 | 369 | 370 | 371 | 372 | 373 | 374 | 375 | 376 | 377 | 378 | 379 | 380 | 381 | 382 | 383 | 384 | 385 | 386 | 387 | 388 | 389 | 390 | 391 | 392 | 393 | 394 | 395 | 396 | 397 | 398 | 399 | 400 | 401 | 402 | 403 | 404 | 405 | 406 | 407 | 408 | 409 | 410 | 411 | 412 | 413 | 414 | 415 | 416 | 417 | 418 | 419 | 420 | 421 | 422 | 423 | 424 | 425 | 426 | 427 | 428 | 429 | 430 | 431 | 432 | 433 | 434 | 435 | 436 | 437 | 438 | 439 | 440 | 441 | 442 | 443 | 444 | 445 | 446 | 447 | 448 | 449 | 450 | 451 | 452 | 453 | 454 | 455 | 456 | 457 | 458 | 459 | 460 | 461 | 462 | 463 | 464 | 465 | 466 | 467 | 468 | 469 | 470 | 471 | 472 | 473 | 474 | 475 | 476 | 477 | 478 | 479 | 480 | 481 | 482 | 483 | 484 | 485 | 486 | 487 | 488 | 489 | 490 | 491 | 492 | 493 | 494 | 495 | 496 | 497 | 498 | 499 | 500 | 501 | 502 | 503 | 504 | 505 | 506 | 507 | 508 | 509 | 510 | 511 | 512 | 513 | 514 | 515 | 516 | 517 | 518 | 519 | 520 | 521 | 522 | 523 | 524 | 525 | 526 | 527 | 528 | 529 | 530 | 531 | 532 | 533 | 534 | 535 | 536 | 537 | 538 | 539 | 540 | 541 | 542 | 543 | 544 | 545 | 546 | 547 | 548 | 549 | 550 | 551 | 552 | 553 | 554 | 555 | 556 | 557 | 558 | 559 | 560 | 561 | 562 | 563 | 564 | 565 | 566 | 567 | 568 | 569 | 570 | 571 | 572 | 573 | 574 | 575 | 576 | 577 | 578 | 579 | 580 | 581 | 582 | 583 | 584 | 585 | 586 | 587 | 588 | 589 | 590 | 591 | 592 | 593 | 594 | 595 | 596 | 597 | 598 | 599 | 600 | 601 | 602 | 603 | 604 | 605 | 606 | 607 | 608 | 609 | 610 | 611 | 612 | 613 | 614 | 615 | 616 | 617 | 618 | 619 | 620 | 621 | 622 | 623 | 624 | 625 | 626 | 627 | 628 | 629 | 630 | 631 | 632 | 633 | 634 | 635 | 636 | 637 | 638 | 639 | 640 | 641 | 642 | 643 | 644 | 645 | 646 | 647 | 648 | 649 | 650 | 651 | 652 | -------------------------------------------------------------------------------- /index.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "metadata": {}, 6 | "source": [ 7 | "# Books with Jupyter Notebooks\n", 8 | "\n", 9 | "The `d2lbook` package helps you build and publish a book consists with\n", 10 | "multiple Jupyter notebooks. It assumes all notebooks are saved in the Markdown\n", 11 | "format with outputs striped in favor of editing and reviewing. It then evaluates\n", 12 | "notebooks to obtain code cell outputs and build them to various formats,\n", 13 | "including Jupyter notebook, HTML and PDF.\n", 14 | "\n", 15 | "In addition, it provides extra functionalities such as:\n", 16 | "\n", 17 | "1. Reference sections, figures, and tables with labels.\n", 18 | "1. Cite references with bibtex.\n", 19 | "1. Evaluate notebooks in parallel with GPU supports (under developing).\n", 20 | "\n", 21 | "Check [Dive into Deep Learning](https://d2l.ai/) for an example built with\n", 22 | "`d2lbook`.\n", 23 | "\n", 24 | "\n", 25 | "## Getting Started\n", 26 | "\n", 27 | "### Installation\n", 28 | "\n", 29 | "Use `pip` to install the command-line interface." 30 | ] 31 | }, 32 | { 33 | "cell_type": "markdown", 34 | "metadata": {}, 35 | "source": [ 36 | "```sh\n", 37 | "pip install git+https://github.com/d2l-ai/d2l-book\n", 38 | "```\n" 39 | ] 40 | }, 41 | { 42 | "cell_type": "markdown", 43 | "metadata": {}, 44 | "source": [ 45 | "In addition, you also need to install `pandoc`, e.g. `conda install pandoc`.\n", 46 | "\n", 47 | "\n", 48 | "### Create a new book (under developing)\n", 49 | "\n", 50 | "Create a new book into the directory `mybook` with a default configuration\n", 51 | "file." 52 | ] 53 | }, 54 | { 55 | "cell_type": "markdown", 56 | "metadata": {}, 57 | "source": [ 58 | "```sh\n", 59 | "d2lbook create mybook\n", 60 | "```\n" 61 | ] 62 | }, 63 | { 64 | "cell_type": "markdown", 65 | "metadata": {}, 66 | "source": [ 67 | "Or create a new book using the demo book content (the website that you’re viewing\n", 68 | "now)." 69 | ] 70 | }, 71 | { 72 | "cell_type": "markdown", 73 | "metadata": {}, 74 | "source": [ 75 | "```sh\n", 76 | "d2lbook create mybook --demo\n", 77 | "```\n" 78 | ] 79 | }, 80 | { 81 | "cell_type": "markdown", 82 | "metadata": {}, 83 | "source": [ 84 | "Edit the `config.ini` by updating the book title, authors, and others.\n", 85 | "\n", 86 | "### Build the contents for your book\n", 87 | "\n", 88 | "First enter your book directory" 89 | ] 90 | }, 91 | { 92 | "cell_type": "markdown", 93 | "metadata": {}, 94 | "source": [ 95 | "```sh\n", 96 | "cd mybook\n", 97 | "```\n" 98 | ] 99 | }, 100 | { 101 | "cell_type": "markdown", 102 | "metadata": {}, 103 | "source": [ 104 | "The following command will evaluate all notebooks and generate outputs in\n", 105 | "`ipynb`, `html` and `pdf` format." 106 | ] 107 | }, 108 | { 109 | "cell_type": "markdown", 110 | "metadata": {}, 111 | "source": [ 112 | "```sh\n", 113 | "d2lbook build all\n", 114 | "```\n" 115 | ] 116 | }, 117 | { 118 | "cell_type": "markdown", 119 | "metadata": {}, 120 | "source": [ 121 | "Once finished, you can check the results in the `_build` folder.\n", 122 | "\n", 123 | "Or you can only build HTML outputs" 124 | ] 125 | }, 126 | { 127 | "cell_type": "markdown", 128 | "metadata": {}, 129 | "source": [ 130 | "```\n", 131 | "d2lbook build html\n", 132 | "```\n" 133 | ] 134 | }, 135 | { 136 | "cell_type": "markdown", 137 | "metadata": {}, 138 | "source": [ 139 | "### Deploy the contents online\n", 140 | "\n", 141 | "Publish both HTML and PDF into a s3 bucket, which allows to setup a static\n", 142 | "website hosting easily (you need to configure the `s3_bucket` in `config.ini`)." 143 | ] 144 | }, 145 | { 146 | "cell_type": "markdown", 147 | "metadata": {}, 148 | "source": [ 149 | "```sh\n", 150 | "d2l-book deploy html pdf\n", 151 | "```\n" 152 | ] 153 | }, 154 | { 155 | "cell_type": "markdown", 156 | "metadata": {}, 157 | "source": [ 158 | "Or push all notebooks in the `ipynb` format into a github repo (you need\n", 159 | "configure `github_repo` in `config.ini`) (under developing)." 160 | ] 161 | }, 162 | { 163 | "cell_type": "markdown", 164 | "metadata": {}, 165 | "source": [ 166 | "```sh\n", 167 | "d2l-book deploy ipynb\n", 168 | "```\n" 169 | ] 170 | }, 171 | { 172 | "cell_type": "markdown", 173 | "metadata": {}, 174 | "source": [ 175 | "## Table of Contents" 176 | ] 177 | }, 178 | { 179 | "cell_type": "markdown", 180 | "metadata": {}, 181 | "source": [ 182 | "```toc\n", 183 | ":numbered:\n", 184 | ":maxdepth: 2\n", 185 | "\n", 186 | "examples/index\n", 187 | "develop/index\n", 188 | "```\n" 189 | ] 190 | }, 191 | { 192 | "cell_type": "markdown", 193 | "metadata": {}, 194 | "source": [ 195 | "## History\n", 196 | "\n", 197 | "This project starts with several scripts wrote to build the documents sites for\n", 198 | "several projects, including [Apache MXNet](http://mxnet.io),\n", 199 | "[GluonCV](http://gluon-cv.mxnet.io), [D2L](http://d2l.ai). Later on, heavily inspired\n", 200 | "by [Jupyter Book](https://jupyter.org/jupyter-book), we refactored these scripts\n", 201 | "into a package." 202 | ] 203 | } 204 | ], 205 | "metadata": { 206 | "kernelspec": { 207 | "display_name": "Python 3", 208 | "name": "python3" 209 | }, 210 | "language_info": { 211 | "name": "python" 212 | } 213 | }, 214 | "nbformat": 4, 215 | "nbformat_minor": 2 216 | } -------------------------------------------------------------------------------- /refs.bib: -------------------------------------------------------------------------------- 1 | @inproceedings{krizhevsky2012imagenet, 2 | title={Imagenet classification with deep convolutional neural networks}, 3 | author={Krizhevsky, Alex and Sutskever, Ilya and Hinton, Geoffrey E}, 4 | booktitle={Advances in neural information processing systems}, 5 | pages={1097--1105}, 6 | year={2012} 7 | } 8 | 9 | @inproceedings{he2016deep, 10 | title={Deep residual learning for image recognition}, 11 | author={He, Kaiming and Zhang, Xiangyu and Ren, Shaoqing and Sun, Jian}, 12 | booktitle={Proceedings of the IEEE conference on computer vision and pattern recognition}, 13 | pages={770--778}, 14 | year={2016} 15 | } 16 | 17 | @article{devlin2018bert, 18 | title={Bert: Pre-training of deep bidirectional transformers for language understanding}, 19 | author={Devlin, Jacob and Chang, Ming-Wei and Lee, Kenton and Toutanova, Kristina}, 20 | journal={arXiv preprint arXiv:1810.04805}, 21 | year={2018} 22 | } 23 | 24 | @TechReport{mitchell80, 25 | author = "T. M. Mitchell", 26 | title = "The Need for Biases in Learning Generalizations", 27 | institution = "Computer Science Department, Rutgers University", 28 | year = "1980", 29 | address = "New Brunswick, MA", 30 | } 31 | 32 | @InCollection{Newell81, 33 | author = "A. Newell and P. S. Rosenbloom", 34 | title = "Mechanisms of Skill Acquisition and the Law of 35 | Practice", 36 | booktitle = "Cognitive Skills and Their Acquisition", 37 | pages = "1--51", 38 | publisher = "Lawrence Erlbaum Associates, Inc.", 39 | year = "1981", 40 | editor = "J. R. Anderson", 41 | chapter = "1", 42 | address = "Hillsdale, NJ", 43 | eprint = {arXiv:1510.01797}, 44 | } 45 | --------------------------------------------------------------------------------