Skip to content

Commit 2e431d1

Browse files
committed
Merge branch 'master' of github.com:fastai/fastbook
2 parents 03a9b43 + fb7e2b8 commit 2e431d1

16 files changed

+183
-57
lines changed

Diff for: 01_intro.ipynb

+14-2
Original file line numberDiff line numberDiff line change
@@ -923,7 +923,7 @@
923923
"cell_type": "markdown",
924924
"metadata": {},
925925
"source": [
926-
"There a number of powerful concepts embedded in this short statement: \n",
926+
"There are a number of powerful concepts embedded in this short statement: \n",
927927
"\n",
928928
"- the idea of a \"weight assignment\" \n",
929929
"- the fact that every weight assignment has some \"actual performance\"\n",
@@ -1526,7 +1526,7 @@
15261526
" label_func=is_cat, item_tfms=Resize(224))\n",
15271527
"```\n",
15281528
"\n",
1529-
"The fourth line tells fastai what kind of dataset we have, and how it is structured. There are various different classes for different kinds of deep learning dataset and problem--here we're using `ImageDataLoaders`. The first part of the class name will generally be the type of data you have, such as image, or text. The second part will generally be the type of problem you are solving, such as classification, or regression.\n",
1529+
"The fourth line tells fastai what kind of dataset we have, and how it is structured. There are various different classes for different kinds of deep learning datasets and problems--here we're using `ImageDataLoaders`. The first part of the class name will generally be the type of data you have, such as image, or text. The second part will generally be the type of problem you are solving, such as classification, or regression.\n",
15301530
"\n",
15311531
"The other important piece of information that we have to tell fastai is how to get the labels from the dataset. Computer vision datasets are normally structured in such a way that the label for an image is part of the file name, or path, most commonly the parent folder name. Fastai comes with a number of standardized labelling methods, and ways to write your own. Here we define a function on the third line: `is_cat` which labels cats based on a filename rule provided by the dataset creators.\n",
15321532
"\n",
@@ -2914,6 +2914,18 @@
29142914
"display_name": "Python 3",
29152915
"language": "python",
29162916
"name": "python3"
2917+
},
2918+
"language_info": {
2919+
"codemirror_mode": {
2920+
"name": "ipython",
2921+
"version": 3
2922+
},
2923+
"file_extension": ".py",
2924+
"mimetype": "text/x-python",
2925+
"name": "python",
2926+
"nbconvert_exporter": "python",
2927+
"pygments_lexer": "ipython3",
2928+
"version": "3.7.4"
29172929
}
29182930
},
29192931
"nbformat": 4,

Diff for: 02_production.ipynb

+23-11
Large diffs are not rendered by default.

Diff for: 03_ethics.ipynb

+19-4
Original file line numberDiff line numberDiff line change
@@ -196,15 +196,15 @@
196196
"source": [
197197
"Of course, the project managers and engineers and technicians involved were just living their ordinary lives. Caring for their families, going to the church on Sunday, doing their jobs as best as they could. Following orders. The marketers were just doing what they could to meet their business development goals. Edwin Black, author of \"IBM and the Holocaust\", said: \"To the blind technocrat, the means were more important than the ends. The destruction of the Jewish people became even less important because the invigorating nature of IBM's technical achievement was only heightened by the fantastical profits to be made at a time when bread lines stretched across the world.\"\n",
198198
"\n",
199-
"Step back for a moment and consider: how would you feel if you discovered that you had been part of a system that ending up hurting society? Would you even know? Would you be open to finding out? How can you help make sure this doesn't happen? We have described the most extreme situation here in Nazi Germany, but there are many negative societal consequences happening due to AI and machine learning right now, some of which we'll describe in this chapter.\n",
199+
"Step back for a moment and consider: how would you feel if you discovered that you had been part of a system that ended up hurting society? Would you even know? Would you be open to finding out? How can you help make sure this doesn't happen? We have described the most extreme situation here in Nazi Germany, but there are many negative societal consequences happening due to AI and machine learning right now, some of which we'll describe in this chapter.\n",
200200
"\n",
201201
"It's not just a moral burden either. Sometimes, technologists pay very directly for their actions. For instance, the first person who was jailed as a result of the Volkswagen scandal, where the car company cheated on their diesel emissions tests, was not the manager that oversaw the project, or an executive at the helm of the company. It was one of the engineers, James Liang, who just did what he was told.\n",
202202
"\n",
203203
"On the other hand, if a project you are involved in turns out to make a huge positive impact on even one person, this is going to make you feel pretty great!\n",
204204
"\n",
205205
"Okay, so hopefully we have convinced you that you ought to care. But what should you do? As data scientists, we're naturally inclined to focus on making our model better at optimizing some metric. But optimizing that metric may not actually lead to better outcomes. And even if optimizing that metric *does* help create better outcomes, it almost certainly won't be the only thing that matters. Consider the pipeline of steps that occurs between the development of a model or an algorithm by a researcher or practitioner, and the point at which this work is actually used to make some decision. This entire pipeline needs to be considered *as a whole* if we're to have a hope of getting the kinds of outcomes we want.\n",
206206
"\n",
207-
"Normally there is a very long chain from one end to the other. This is especially true if you are a researcher where you don't even know if your research will ever get used for anything, or if you're involved in data collection, which is even earlier in the pipeline. But no-one is better placed to inform everyone involved in this chain about the capabilities, constraints, and details of your work than you are. Although there's no \"silver bullet\" that can ensure your work is used the right way, by getting involved in the process, and asking the right questions, you can at the very least ensured that the right issues are being considered.\n",
207+
"Normally there is a very long chain from one end to the other. This is especially true if you are a researcher where you don't even know if your research will ever get used for anything, or if you're involved in data collection, which is even earlier in the pipeline. But no-one is better placed to inform everyone involved in this chain about the capabilities, constraints, and details of your work than you are. Although there's no \"silver bullet\" that can ensure your work is used the right way, by getting involved in the process, and asking the right questions, you can at the very least ensure that the right issues are being considered.\n",
208208
"\n",
209209
"Sometimes, the right response to being asked to do a piece of work is to just say \"no\". Often, however, the response we hear is \"if I don’t do it, someone else will\". But consider this: if you’ve been picked for the job, you’re the best person they’ve found; so if you don’t do it, the best person isn’t working on that project. If the first 5 they ask all say no too, then even better!"
210210
]
@@ -700,7 +700,7 @@
700700
"- support good policy\n",
701701
"- increase diversity\n",
702702
"\n",
703-
"Let's walk through each step next, staring with analyzing a project you are working on."
703+
"Let's walk through each step next, starting with analyzing a project you are working on."
704704
]
705705
},
706706
{
@@ -726,7 +726,7 @@
726726
"\n",
727727
"These questions may be able to help you identify outstanding issues, and possible alternatives that are easier to understand and control. In addition to asking the right questions, it's also important to consider practices and processes to implement.\n",
728728
"\n",
729-
"One thing to consider at this stage is what data you are collecting and storing. Data often ends up being used for different purposes than why it was originally collected. For instance, IBM began selling to Nazi Germany well before the Holocaust, including helping with Germany’s 1933 census conducted by Adolf Hitler, which was effective at identifying far more Jewish people than had previously been recognized in Germany. US census data was used to round up Japanese-Americans (who were US citizens) for internment during World War II. It is important to recognize how data and images collected can be weaponized later. Columbia professor [Tim Wu wrote](https://www.nytimes.com/2019/04/10/opinion/sunday/privacy-capitalism.html) that “You must assume that any personal data that Facebook or Android keeps are data that governments around the world will try to get or that thieves will try to steal.”"
729+
"One thing to consider at this stage is what data you are collecting and storing. Data often ends up being used for different purposes than why it was originally collected for. For instance, IBM began selling to Nazi Germany well before the Holocaust, including helping with Germany’s 1933 census conducted by Adolf Hitler, which was effective at identifying far more Jewish people than had previously been recognized in Germany. US census data was used to round up Japanese-Americans (who were US citizens) for internment during World War II. It is important to recognize how data and images collected can be weaponized later. Columbia professor [Tim Wu wrote](https://www.nytimes.com/2019/04/10/opinion/sunday/privacy-capitalism.html) that “You must assume that any personal data that Facebook or Android keeps are data that governments around the world will try to get or that thieves will try to steal.”"
730730
]
731731
},
732732
{
@@ -1034,10 +1034,25 @@
10341034
}
10351035
],
10361036
"metadata": {
1037+
"jupytext": {
1038+
"split_at_heading": true
1039+
},
10371040
"kernelspec": {
10381041
"display_name": "Python 3",
10391042
"language": "python",
10401043
"name": "python3"
1044+
},
1045+
"language_info": {
1046+
"codemirror_mode": {
1047+
"name": "ipython",
1048+
"version": 3
1049+
},
1050+
"file_extension": ".py",
1051+
"mimetype": "text/x-python",
1052+
"name": "python",
1053+
"nbconvert_exporter": "python",
1054+
"pygments_lexer": "ipython3",
1055+
"version": "3.7.4"
10411056
}
10421057
},
10431058
"nbformat": 4,

Diff for: 06_multicat.ipynb

+5-5
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@
191191
"cell_type": "markdown",
192192
"metadata": {},
193193
"source": [
194-
"No, it’s not actually a panda! *Pandas* is a Python library that is used to manipulate and analysis tabular and timeseries data. The main class is `DataFrame`, which represents a table of rows and columns. You can get a DataFrame from a CSV file, a database table, python dictionaries, and many other sources. In Jupyter, a DataFrame is output as a formatted table, as you see above.\n",
194+
"No, it’s not actually a panda! *Pandas* is a Python library that is used to manipulate and analyse tabular and timeseries data. The main class is `DataFrame`, which represents a table of rows and columns. You can get a DataFrame from a CSV file, a database table, python dictionaries, and many other sources. In Jupyter, a DataFrame is output as a formatted table, as you see above.\n",
195195
"\n",
196196
"You can access rows and columns of a DataFrame with the `iloc` property, which lets you access rows and columns as if it is a matrix:"
197197
]
@@ -1192,7 +1192,7 @@
11921192
"source": [
11931193
"In this case, we're using the validation set to pick a hyperparameter (the threshold), which is the purpose of the validation set. But sometimes students have expressed their concern that we might be *overfitting* to the validation set, since we're trying lots of values to see which is the best. However, as you see in the plot, changing the threshold in this case results in a smooth curve, so we're clearly not picking some inappropriate outlier. This is a good example of where you have to be careful of the difference between theory (don't try lots of hyperparameter values or you might overfit the validation set) versus practice (if the relationship is smooth, then it's fine to do this).\n",
11941194
"\n",
1195-
"This concludes the part of thic chapter dedicated to multi-label classification. Let's have a look at a regression problem now."
1195+
"This concludes the part of this chapter dedicated to multi-label classification. Let's have a look at a regression problem now."
11961196
]
11971197
},
11981198
{
@@ -1459,7 +1459,7 @@
14591459
"cell_type": "markdown",
14601460
"metadata": {},
14611461
"source": [
1462-
"> important: We're not aware of other libraries (except for fastai) that automatically and correctly apply data augmentation to coordinates. So if you're working with another library, you may need to disable data augmentation for these kinda of problems."
1462+
"> important: We're not aware of other libraries (except for fastai) that automatically and correctly apply data augmentation to coordinates. So if you're working with another library, you may need to disable data augmentation for these kinds of problems."
14631463
]
14641464
},
14651465
{
@@ -1664,7 +1664,7 @@
16641664
"cell_type": "markdown",
16651665
"metadata": {},
16661666
"source": [
1667-
"This makes sense, since when coordinates are used a dependent variable, most of the time we're likely to be trying to predict something as close as possible; that's basically what `MSELoss` (mean-squared error loss) does. If you want to use a different loss function, you can pass it to `cnn_learner` using the `loss_func` parameter.\n",
1667+
"This makes sense, since when coordinates are used as dependent variable, most of the time we're likely to be trying to predict something as close as possible; that's basically what `MSELoss` (mean-squared error loss) does. If you want to use a different loss function, you can pass it to `cnn_learner` using the `loss_func` parameter.\n",
16681668
"\n",
16691669
"Note also that we didn't specify any metrics. That's because the MSE is already a useful metric for this task (although it's probably more interpretable after we take the square root). \n",
16701670
"\n",
@@ -1858,7 +1858,7 @@
18581858
"cell_type": "markdown",
18591859
"metadata": {},
18601860
"source": [
1861-
"In problems that are at first glance completely different (single-label classification, multi-label classification and regression) we end up using the same model with just different numbers of outputs. The different directions of those trainings is determined by the loss function, which is the one thing that changes. That's why it simportant to double-check your are using the right loss function for your problem.\n",
1861+
"In problems that are at first glance completely different (single-label classification, multi-label classification and regression) we end up using the same model with just different numbers of outputs. The different directions of those trainings is determined by the loss function, which is the one thing that changes. That's why it's important to double-check your are using the right loss function for your problem.\n",
18621862
"\n",
18631863
"In fastai, the library will automatically try to pick the right one from the data you built, but if you are using pure PyTorch to build your `DataLoader`s, make sure you think hard when you have to decide on your loss function, and remember that you most probably want\n",
18641864
"\n",

Diff for: 07_sizing_and_tta.ipynb

+3-3
Original file line numberDiff line numberDiff line change
@@ -389,7 +389,7 @@
389389
"cell_type": "markdown",
390390
"metadata": {},
391391
"source": [
392-
"As we have seen, the kinds of features that are learned by convolutional neural networks are not in any way specific to the size of the image — early layers find things like edges and gradients, and later layers may find things like noses and sunsets. So, when we change image size in the middle of training, it doesn't mean that we have two find totally different parameters for our model.\n",
392+
"As we have seen, the kinds of features that are learned by convolutional neural networks are not in any way specific to the size of the image — early layers find things like edges and gradients, and later layers may find things like noses and sunsets. So, when we change image size in the middle of training, it doesn't mean that we have to find totally different parameters for our model.\n",
393393
"\n",
394394
"But clearly there are some differences between small images and big ones, so we shouldn't expect our model to continue working exactly as well, with no changes at all. Does this remind you of something? When we developed this idea, it reminded us of transfer learning! We are trying to get our model to learn to do something a little bit different to what it has learned to do before. Therefore, we should be able to use the `fine_tune` method after we resize our images.\n",
395395
"\n",
@@ -803,7 +803,7 @@
803803
"source": [
804804
"#hide_input\n",
805805
"#id mixup_example\n",
806-
"#caption Mixing a chruch and a gas station\n",
806+
"#caption Mixing a church and a gas station\n",
807807
"#alt An image of a church, a gas station and the two mixed up.\n",
808808
"church = PILImage.create(get_image_files_sorted(path/'train'/'n03028079')[0])\n",
809809
"gas = PILImage.create(get_image_files_sorted(path/'train'/'n03425413')[0])\n",
@@ -910,7 +910,7 @@
910910
"source": [
911911
"Let's practice our paper reading skills to try to interpret this. \"This maximum\" is refering to the previous section of the paper, which talked about the fact that `1` is the value of the label for the positive class. So any value (except infinity) can't result in `1` after sigmoid or softmax. In a paper, you won't normally see \"any value\" written, but instead it would get a symbol; in this case, it's $z_k$. This is helpful in a paper, because it can be refered to again later, and the reader knows what value is being discussed.\n",
912912
"\n",
913-
"The it says: $z_y\\gg z_k$ for all $k\\neq y$. In this case, the paper immediately follows with \"that is...\", which is handy, because you can just read the English instead of the math. In the math, the $y$ is refering to the target ($y$ is defined earlier in the paper; sometimes it's hard to find where symbols are defined, but nearly all papers will define all their symbols somewhere), and $z_y$ is the activation corresponding to the target. So to get close to `1`, this activation needs to be much higher than all the others for that prediction.\n",
913+
"Then it says: $z_y\\gg z_k$ for all $k\\neq y$. In this case, the paper immediately follows with \"that is...\", which is handy, because you can just read the English instead of the math. In the math, the $y$ is refering to the target ($y$ is defined earlier in the paper; sometimes it's hard to find where symbols are defined, but nearly all papers will define all their symbols somewhere), and $z_y$ is the activation corresponding to the target. So to get close to `1`, this activation needs to be much higher than all the others for that prediction.\n",
914914
"\n",
915915
"Next up is \"if the model learns to assign full probability to the ground-truth label for each training example, it is not guaranteed to generalize\". This is saying that making $z_y$ really big means we'll need large weights and large activations throughout our model. Large weights lead to \"bumpy\" functions, where a small change in input results in a big change to predictions. This is really bad for generalization, because it means just one pixel changing a bit could change our prediction entirely!\n",
916916
"\n",

0 commit comments

Comments
 (0)