Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
mli committed Dec 27, 2018
2 parents 375b957 + da5a4f5 commit 07ac85f
Show file tree
Hide file tree
Showing 58 changed files with 2,375 additions and 567 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,4 @@ build/chapter*
build/_build
build/img
build/data
build/gluonbook
7 changes: 4 additions & 3 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,16 @@ stage("Sanity Check") {
}
}

stage("Publish") {
stage("Build and Publish") {
node {
ws('workspace/d2l-en') {
checkout scm
sh """#!/bin/bash
set -ex
set -e
if [[ ${env.BRANCH_NAME} == master ]]; then
build/utils/upload_notebooks_no_output_github.sh . https://github.com/d2l-ai/notebooks
fi
"""
}
}
}
}
8 changes: 4 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
all: html

build/%.ipynb: %.md build/env.yml build/md2ipynb.py $(wildcard gluonbook/*)
@mkdir -p $(@D)
mkdir -p $(@D)
cd $(@D); python ../md2ipynb.py ../../$< ../../$@

build/%.md: %.md
Expand All @@ -19,17 +19,17 @@ FRONTPAGE = $(wildcard $(FRONTPAGE_DIR)/*)
FRONTPAGE_DEP = $(patsubst %, build/%, $(FRONTPAGE))

IMG_NOTEBOOK = $(filter-out $(FRONTPAGE_DIR), $(wildcard img/*))
ORIGIN_DEPS = $(IMG_NOTEBOOK) $(wildcard data/*) environment.yml README.md
ORIGIN_DEPS = $(IMG_NOTEBOOK) $(wildcard data/* gluonbook/*) environment.yml README.md
DEPS = $(patsubst %, build/%, $(ORIGIN_DEPS))

PKG = build/_build/html/d2l-en.zip

pkg: $(PKG)

build/_build/html/d2l-en.zip: $(OBJ) $(DEPS)
cd build; zip -r $(patsubst build/%, %, $@ $(DEPS)) chapter*
cd build; zip -r $(patsubst build/%, %, $@ $(DEPS)) chapter*/*md chapter*/*ipynb

# Copy everything to build/.
# Copy XX to build/XX if build/XX is depended (e.g., $(DEPS))
build/%: %
@mkdir -p $(@D)
@cp -r $< $@
Expand Down
13 changes: 7 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,16 @@

[![Build Status](http://ci.diveintodeeplearning.org/job/en/job/master/badge/icon)](http://ci.diveintodeeplearning.org/job/en/job/master/)

## Become a D2L contributor, and you will be acknowledged in the book
[[Book website](http://en.diveintodeeplearning.org/)] [[STAT 157 Course at UC Berkeley, Spring 2019](http://courses.diveintodeeplearning.org/berkeley-stat-157/)]

The contents of the book are under revision. We expect that the quality will be constantly improved.

Feel free to contribute to this book ([learn how to contribute](http://en.diveintodeeplearning.org/chapter_appendix/how-to-contribute.html)). All the contributors (Github ID and name, if any) will be acknowledged in the book. We will also negotiate with the press to see if each contributor can receive a free book when published. Once you become a [D2L contributor](https://github.com/diveintodeeplearning/d2l-en/graphs/contributors), please email your Github ID and name to
## Contribute ([learn how](http://en.diveintodeeplearning.org/chapter_appendix/how-to-contribute.html))

> [email protected]
This open source book has benefited from pedagogical suggestions, typo corrections, and other improvements from community contributors. Your help is valuable for making the book better for everyone. We will [acknowledge](http://en.diveintodeeplearning.org/chapter_introduction/preface.html#Acknowledgments) each contributor in the book and send a free book (hard copy) to each contributor when it is published.

Dear contributors, please email your GitHub ID and name to [email protected]. Thanks.


[[Chinese version](https://github.com/diveintodeeplearning)] [[Discuss and report issues](https://discuss.mxnet.io/)]

## Chinese version 《动手学深度学习》

[https://github.com/diveintodeeplearning/d2l-zh](https://github.com/diveintodeeplearning/d2l-zh)
34 changes: 32 additions & 2 deletions build/build_html.sh → build/build_all.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
#!/bin/bash
set -e
set -ex

tik=$(date +%s)

[ -e build/data-bak ] && rm -rf build/data-bak

# Clean build/chapter*/*ipynb and build/chapter*/*md that are no longer needed.
cd build
Expand Down Expand Up @@ -34,7 +38,33 @@ conda env update -f build/env.yml
conda activate d2l-en-build

pip list

rm -rf build/_build/

make html

make pdf
cp build/_build/latex/d2l-en.pdf build/_build/html/

[ -e build/_build/latex/d2l-en.aux ] && rm build/_build/latex/d2l-en.aux
[ -e build/_build/latex/d2l-en.idx ] && rm build/_build/latex/d2l-en.idx

# avoid putting data downloaded by scripts into the notebook package
mv build/data build/data-bak
make pkg
# backup build/data to avoid download the dataset each time and put the
rm -rf build/data
mv build/data-bak build/data

# For 1.0
cp build/_build/html/d2l-en.zip build/_build/html/d2l-en-1.0.zip

# Time it
tok=$(date +%s)
runtime=$((tok-tik))
convertsecs() {
((h=${1}/3600))
((m=(${1}%3600)/60))
((s=${1}%60))
printf "%02d:%02d:%02d\n" $h $m $s
}
echo $(convertsecs $runtime)
11 changes: 0 additions & 11 deletions build/build_pdf.sh

This file was deleted.

12 changes: 0 additions & 12 deletions build/build_pkg.sh

This file was deleted.

11 changes: 6 additions & 5 deletions build/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ def __init__(self, **options):
# General information about the project.
project = 'Dive into Deep Learning'
copyright = '2017--2018, Contributors'
author = "MXNet Community"
author = "A. Zhang, Z. C. Lipton, M. Li, and A. J. Smola"


# The version info for the project you're documenting, acts as replacement for
Expand Down Expand Up @@ -143,11 +143,12 @@ def __init__(self, **options):
'primary_color': 'blue',
'accent_color': 'deep_orange',
'header_links' : [
('Berkeley Course 2019', 'http://courses.diveintodeeplearning.org/berkeley-stat-157/', True, 'fas fa-user-graduate'),
('PDF', 'https://en.diveintodeeplearning.org/d2l-en.pdf', True, 'fas fa-file-pdf'),
('Jupyter Notebooks', './d2l-en.zip', True, 'fas fa-download'),
('Forum', 'https://discuss.mxnet.io', True, 'fab fa-discourse'),
('Github', 'https://github.com/diveintodeeplearning/d2l-en', True, 'fab fa-github'),
('中文版本', 'https://zh.diveintodeeplearning.org', True, 'fas fa-external-link-alt'),
('Jupyter Notebooks', 'http://en.diveintodeeplearning.org/d2l-en.zip', True, 'fas fa-download'),
('Discuss', 'https://discuss.mxnet.io', True, 'fab fa-discourse'),
('GitHub', 'https://github.com/diveintodeeplearning/d2l-en', True, 'fab fa-github'),
('中文版', 'https://zh.diveintodeeplearning.org', True, 'fas fa-external-link-alt'),
],
'show_footer': True
}
Expand Down
2 changes: 1 addition & 1 deletion build/env.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@ dependencies:
- nbsphinx==0.3.5
- recommonmark==0.4.0
- https://github.com/mli/notedown/tarball/master
- mxnet-cu92==1.2.1
- mxnet-cu92==1.2.0
- gluonbook==0.8.5
- awscli
6 changes: 3 additions & 3 deletions build/frontpage.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ <h2>Dive into Deep Learning</h2>
<div class = "mdl-cell mdl-cell--3-col mdl-cell--top">
<div class="author-item">
<img src="./_images/frontpage/aston.jpg"/>
<h3><a href="https://astonzhang.github.io/">Aston Zhang </a></h3>
<h3><a href="https://www.astonzhang.com/">Aston Zhang </a></h3>
<p>Amazon Applied Scientist<br>UIUC Ph.D.</p>
</div>
</div>
Expand Down Expand Up @@ -48,8 +48,8 @@ <h3><a href="https://alex.smola.org/">Alex J. Smola</a></h3>
</p>
</div>
</div>
<h3> We thank all the <a href="https://github.com/diveintodeeplearning/d2l-en/graphs/contributors">D2L contributors</a> for improving the book.</h3>
<h4><a href="https://github.com/diveintodeeplearning/d2l-en/blob/master/README.md#become-a-d2l-contributor-and-you-will-be-acknowledged-in-the-book">Become a D2L contributor, and you will be acknowledged in the book.</a></h4>
<h3> We thank all the <a href="https://github.com/diveintodeeplearning/d2l-en/graphs/contributors">community contributors</a><br>for making this open source book better for everyone.</h3>
<h4><a href="https://github.com/diveintodeeplearning/d2l-en/blob/master/README.md#contribute-learn-how">Contribute to the book.</a></h4>
</div>

<div class = "features mdl-grid">
Expand Down
31 changes: 31 additions & 0 deletions build/lint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#!/bin/bash

# Prerequisite: pip install nblint
# Run 'bash build/lint.sh'
# Check results in outlint

OUT=outlint

[ -e $OUT ] && rm $OUT

for f in build/chapter*/*.ipynb; do
echo '===' $f
echo '===' $f >> $OUT
nblint --linter pyflakes $f >> $OUT
nblint $f >> $OUT
done

# E302 expected 2 blank lines, found 1
# E305 expected 2 blank lines after class or function definition, found 1
# E402 module level import not at top of file
# E703 statement ends with a semicolon
# E741 ambiguous variable name
IGNORE=( 'E302'
'E305'
'E402'
'E703'
'E741' )

for ign in "${IGNORE[@]}"; do
sed -i /$ign/d $OUT
done
18 changes: 11 additions & 7 deletions build/upload.sh
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
#!/bin/bash
set -e
set -x

conda activate d2l-en-build

BUCKET=s3://diveintodeeplearning.org
#BUCKET=s3://diveintodeeplearning.org
# BUCKET=s3://diveintodeeplearning-staging

DIR=build/_build/html/

aws s3 sync --delete $DIR s3://diveintodeeplearning.org --acl 'public-read' --quiet
aws s3 sync --delete $DIR s3://en.d2l.ai --acl 'public-read' --quiet

#find $DIR \( -iname '*.css' -o -iname '*.js' \) -exec gzip -9 -n {} \; -exec mv {}.gz {} \;

#aws s3 sync --exclude '*.*' --include '*.css' \
Expand All @@ -17,17 +19,19 @@ DIR=build/_build/html/
# --acl 'public-read' \
# $DIR $BUCKET

aws s3 sync --exclude '*.*' --include '*.woff' --include '*.woff2' \
--expires "$(date -d '+24 months' --utc +'%Y-%m-%dT%H:%M:%SZ')" \
--acl 'public-read' \
$DIR $BUCKET
#aws s3 sync --exclude '*.*' --include '*.woff' --include '*.woff2' \
# --expires "$(date -d '+24 months' --utc +'%Y-%m-%dT%H:%M:%SZ')" \
# --acl 'public-read' --quiet \
# $DIR $BUCKET

#aws s3 sync --exclude '*.*' --include '*.js' \
# --content-type 'application/javascript' \
# --content-encoding 'gzip' \
# --acl 'public-read' \
# $DIR $BUCKET

aws s3 sync --delete $DIR $BUCKET --acl 'public-read'
#aws s3 sync --delete $DIR $BUCKET --acl 'public-read' --quiet

echo 's3 uploaded'

# TODO: add cache control
2 changes: 1 addition & 1 deletion chapter_appendix/gluonbook.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
| `Residual`|[Residual Networks (ResNet)](../chapter_convolutional-neural-networks/resnet.md)|
| `resnet18`|[Gluon Implementation for Multi-GPU Computing](../chapter_computational-performance/multiple-gpus-gluon.md)|
| `RNNModel`|[Gluon Implementation for Recurrent Neural Networks](../chapter_recurrent-neural-networks/rnn-gluon.md)|
|`semilogy` |[Model Selection, Underfitting, and Overfitting](../chapter_deep-learning-basics/underfit-overfit.md)|
|`semilogy` |[Model Selection](../chapter_deep-learning-basics/underfit-overfit.md)|
| `set_figsize`|[Implementation of Linear Regression Starting from Scratch](../chapter_deep-learning-basics/linear-regression-scratch.md)|
| `sgd`|[Implementation of Linear Regression Starting from Scratch](../chapter_deep-learning-basics/linear-regression-scratch.md)|
| `show_bboxes`|[Anchor Boxes](../chapter_computer-vision/anchor.md)|
Expand Down
24 changes: 9 additions & 15 deletions chapter_appendix/how-to-contribute.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
# How to Contribute to This Book

In the "Acknowledgments" section of this book, we thank all the contributors to this book and list their GitHub IDs or names.

You can view the list of contributors [1] in the GitHub code repository for this book. If you want to be one of the contributors to this book, you need to install Git and submit a pull request[2] for the GitHub code repository of this book. When your pull request is merged into the code repository by the author of this book, you will become a contributor.
You can view the list of contributors [1] for this open-sourced book. If you want to contribute to this book, you need to install Git and submit a pull request [2] for the GitHub code repository of this book. When your pull request is merged into the code repository by the author of this book, you will become a contributor.

This section describes the basic Git procedure for contributing to this book. If you are familiar with Git operations, you can skip this section.

Expand All @@ -12,15 +10,15 @@ Step 1: Install Git. The Git open source book details how to install Git [3]. If

Step 2: Log in to GitHub. Enter the address of code repository of this book in your browser [2]. Click on the "Fork" button in the red box at the top-right of Figure 11.20 to get a copy of code repository of this book.

![The code repository page. ](../img/contrib01.png)
![The code repository page.](../img/contrib01.png)


Now, the code repository of this book will be copied to your username, such as "Your GitHub ID/d2l-en" shown at the top-left of Figure 11.21.

![Copy the code repository. ](../img/contrib02.png)
![Copy the code repository.](../img/contrib02.png)


Step 3: Click the green "Clone or download" button on the right side of Figure 11.21 and click the button in the red box to copy the code repository address under your username. Follow the method described in the ["Acquiring and Running Codes in This Book"](../chapter_prerequisite/install.md) section to enter command line mode. Here, we assume you want to save the code repository under the local "~/repo" path. Go to this path, type `git clone `, and paste the code repository address under your username. Execute the command:
Step 3: Click the green "Clone or download" button on the right side of Figure 11.21 and click the button in the red box to copy the code repository address under your username. Follow the method described in the ["Acquiring and Running Codes in This Book"](../chapter_prerequisite/install.md) section to enter command line mode. Here, we assume you want to save the code repository under the local "~/repo" path. Go to this path, type `git clone`, and paste the code repository address under your username. Execute the command:

```
# Replace your_Github_ID with your GitHub username.
Expand All @@ -38,7 +36,7 @@ git status

At this point Git will prompt that the "chapter_deep-learning-basics/linear-regression.md" file has been modified, as shown in Figure 11.22.

![Git prompts that the "chapter_deep-learning-basics/linear-regression.md" file has been modified. ](../img/contrib03.png)
![Git prompts that the chapter_deep-learning-basics/linear-regression.md file has been modified.](../img/contrib03.png)

After confirming the file submitting the change, execute the following command:

Expand All @@ -50,23 +48,19 @@ git push

Here, `'fix typo in linear-regression.md'` is the description of the submitted change. You can replace this with other meaningful descriptive information.

Step 5: Enter the code repository address of this book [2] in your browser again. Click the "New pull request" button in the red box on the bottom-left of Figure 11.20. On the page that appears, click the "compare across forks" link in the red box on the right side of Figure 11.23. Then, click the "head fork: diveintodeeplearning/d2l-en" button in the red box below. Enter your GitHub ID in the pop-up text box and select "Your GitHub-ID/d2l-en" from the drop-down menu, as shown in Figure 11.23.

Step 5: Enter the code repository address of this book[2] in your browser again. Click the "New pull request" button in the red box on the left of Figure 11.20. On the page that appears, click the "compare across forks" link in the red box on the right side of Figure 11.23. Then, click the "head fork: diveintodeeplearning/d2l-en" button in the red box below. Enter your GitHub ID in the pop-up text box and select "Your GitHub-ID/d2l-en" from the drop-down menu, as shown in Figure 11.23.


![Select the code repository where the source of the change is located. ](../img/contrib04.png)
![Select the code repository where the source of the change is located.](../img/contrib04.png)


Step 6: As shown in Figure 11.24, describe the pull request you want to submit in the title and body text boxes. Click the green "Create pull request" button in the red box to submit the pull request.

![Describe and submit a pull request. ](../img/contrib05.png)
![Describe and submit a pull request.](../img/contrib05.png)


After submitting the request, you will see the page shown in Figure 11.25, which indicates that the pull request has been submitted.

![The pull request has been submitted. ](../img/contrib06.png)


![The pull request has been submitted.](../img/contrib06.png)


## Summary
Expand Down
6 changes: 3 additions & 3 deletions chapter_appendix/math.md
Original file line number Diff line number Diff line change
Expand Up @@ -112,10 +112,10 @@ Define a scalar $k$. Multiplication of scalars and matrices is also an element-w
$$
k\boldsymbol{A} =
\begin{bmatrix}
ka_{11} & ka_{21} & \dots & ka_{m1} \\
ka_{12} & ka_{22} & \dots & ka_{m2} \\
ka_{11} & ka_{12} & \dots & ka_{1n} \\
ka_{21} & ka_{22} & \dots & ka_{2n} \\
\vdots & \vdots & \ddots & \vdots \\
ka_{1n} & ka_{2n} & \dots & ka_{mn}
ka_{m1} & ka_{m2} & \dots & ka_{mn}
\end{bmatrix}.
$$

Expand Down
2 changes: 1 addition & 1 deletion chapter_computational-performance/async-computation.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Asynchronous Programming
# Asynchronous Computing

MXNet utilizes asynchronous programming to improve computing performance. Understanding how asynchronous programming works helps us to develop more efficient programs, by proactively reducing computational requirements and thereby minimizing the memory overhead required in the case of limited memory resources. First, we will import the package or module needed for this section’s experiment.

Expand Down
4 changes: 2 additions & 2 deletions chapter_computational-performance/auto-parallelism.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Automatic Parallel Computation
# Automatic Parallelism

MXNet automatically constructs computational graphs at the back end. Using a computational graph, the system is aware of all the computational dependencies, and can selectively execute multiple non-interdependent tasks in parallel to improve computing performance. For instance, the first example in the [“Asynchronous Computation](async-computation.md) section executes `a = nd.ones((1, 2))` and `b = nd.ones((1, 2))` in turn. There is no dependency between these two steps, so the system can choose to execute them in parallel.
MXNet automatically constructs computational graphs at the back end. Using a computational graph, the system is aware of all the computational dependencies, and can selectively execute multiple non-interdependent tasks in parallel to improve computing performance. For instance, the first example in the [“Asynchronous Computing](async-computation.md) section executes `a = nd.ones((1, 2))` and `b = nd.ones((1, 2))` in turn. There is no dependency between these two steps, so the system can choose to execute them in parallel.

Typically, a single operator will use all the computational resources on all CPUs or a single GPU. For example, the `dot` operator will use all threads on all CPUs (even if there are multiple CPU processors on a single machine) or a single GPU. If computational load of each operator is large enough and multiple operators are run in parallel on only on the CPU or a single GPU, then the operations of each operator can only receive a portion of computational resources of CPU or single GPU. Even if these computations can be parallelized, the ultimate increase in computing performance may not be significant. In this section, our discussion of automatic parallel computation mainly focuses on parallel computation using both CPUs and GPUs, as well as the parallelization of computation and communication.

Expand Down
2 changes: 1 addition & 1 deletion chapter_computational-performance/index.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Computing Performance
# Computational Performance

In deep learning, data sets are usually large and model computation is complex. Therefore, we are always very concerned about computing performance. This chapter will focus on the important factors that affect computing performance: imperative programming, symbolic programming, asynchronous programing, automatic parallel computation, and multi-GPU computation. By studying this chapter, you should be able to further improve the computing performance of the models that have been implemented in the previous chapters, for example, by reducing the model training time without affecting the accuracy of the model.

Expand Down
2 changes: 1 addition & 1 deletion chapter_computer-vision/kaggle-gluon-cifar10.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Get Started with Kaggle Competition: Image Classification (CIFAR-10)
# Image Classification (CIFAR-10) on Kaggle

So far, we have been using Gluon's `data` package to directly obtain image data sets in NDArray format. In practice, however, image data sets often exist in the format of image files. In this section, we will start with the original image files and organize, read, and convert the files to NDArray format step by step.

Expand Down
Loading

0 comments on commit 07ac85f

Please sign in to comment.