Skip to content

Commit

Permalink
Update and add clean
Browse files Browse the repository at this point in the history
  • Loading branch information
sgugger committed Mar 6, 2020
1 parent e87f1d5 commit b2f1c12
Show file tree
Hide file tree
Showing 196 changed files with 33,475 additions and 306 deletions.
57 changes: 23 additions & 34 deletions 01_intro.ipynb

Large diffs are not rendered by default.

18 changes: 3 additions & 15 deletions 02_production.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -1629,7 +1629,8 @@
],
"source": [
"#hide_output\n",
"VBox([widgets.Label('Select your bear!'), btn_upload, btn_run, out_pl, lbl_pred])"
"VBox([widgets.Label('Select your bear!'), \n",
" btn_upload, btn_run, out_pl, lbl_pred])"
]
},
{
Expand Down Expand Up @@ -1946,20 +1947,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.7.5"
},
"toc": {
"base_numbering": 1,
"nav_menu": {},
"number_sections": false,
"sideBar": true,
"skip_h1_title": true,
"title_cell": "Table of Contents",
"title_sidebar": "Contents",
"toc_cell": false,
"toc_position": {},
"toc_section_display": true,
"toc_window_display": false
"version": "3.7.4"
}
},
"nbformat": 4,
Expand Down
28 changes: 0 additions & 28 deletions 03_ethics.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -1041,34 +1041,6 @@
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.7.5"
},
"toc": {
"base_numbering": 1,
"nav_menu": {
"height": "600px",
"width": "365px"
},
"number_sections": false,
"sideBar": true,
"skip_h1_title": true,
"title_cell": "Table of Contents",
"title_sidebar": "Contents",
"toc_cell": false,
"toc_position": {},
"toc_section_display": true,
"toc_window_display": false
}
},
"nbformat": 4,
Expand Down
15 changes: 1 addition & 14 deletions 05_pet_breeds.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -2543,20 +2543,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.7.5"
},
"toc": {
"base_numbering": 1,
"nav_menu": {},
"number_sections": false,
"sideBar": true,
"skip_h1_title": true,
"title_cell": "Table of Contents",
"title_sidebar": "Contents",
"toc_cell": false,
"toc_position": {},
"toc_section_display": true,
"toc_window_display": false
"version": "3.7.4"
}
},
"nbformat": 4,
Expand Down
25 changes: 20 additions & 5 deletions 06_multicat.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -1445,11 +1445,14 @@
"metadata": {},
"outputs": [],
"source": [
"biwi = DataBlock(blocks=(ImageBlock, PointBlock),\n",
" get_items=get_image_files,\n",
" get_y=get_ctr,\n",
" splitter=FuncSplitter(lambda o: o.parent.name=='13'),\n",
" batch_tfms=[*aug_transforms(size=(240,320)), Normalize.from_stats(*imagenet_stats)])"
"biwi = DataBlock(\n",
" blocks=(ImageBlock, PointBlock),\n",
" get_items=get_image_files,\n",
" get_y=get_ctr,\n",
" splitter=FuncSplitter(lambda o: o.parent.name=='13'),\n",
" batch_tfms=[*aug_transforms(size=(240,320)), \n",
" Normalize.from_stats(*imagenet_stats)]\n",
")"
]
},
{
Expand Down Expand Up @@ -1925,6 +1928,18 @@
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.7.4"
}
},
"nbformat": 4,
Expand Down
15 changes: 14 additions & 1 deletion 07_sizing_and_tta.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -460,7 +460,8 @@
],
"source": [
"dls = get_dls(128, 128)\n",
"learn = Learner(dls, xresnet50(), loss_func=CrossEntropyLossFlat(), metrics=accuracy)\n",
"learn = Learner(dls, xresnet50(), loss_func=CrossEntropyLossFlat(), \n",
" metrics=accuracy)\n",
"learn.fit_one_cycle(4, 3e-3)"
]
},
Expand Down Expand Up @@ -1011,6 +1012,18 @@
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.7.4"
}
},
"nbformat": 4,
Expand Down
12 changes: 12 additions & 0 deletions 08_collab.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -2296,6 +2296,18 @@
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.7.4"
}
},
"nbformat": 4,
Expand Down
25 changes: 0 additions & 25 deletions 09_tabular.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -9740,31 +9740,6 @@
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.7.5"
},
"toc": {
"base_numbering": 1,
"nav_menu": {},
"number_sections": false,
"sideBar": true,
"skip_h1_title": true,
"title_cell": "Table of Contents",
"title_sidebar": "Contents",
"toc_cell": false,
"toc_position": {},
"toc_section_display": true,
"toc_window_display": false
}
},
"nbformat": 4,
Expand Down
21 changes: 5 additions & 16 deletions 10_nlp.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -1708,7 +1708,8 @@
"TEXT = \"I liked this movie because\"\n",
"N_WORDS = 40\n",
"N_SENTENCES = 2\n",
"preds = [learn.predict(TEXT, N_WORDS, temperature=0.75) for _ in range(N_SENTENCES)]"
"preds = [learn.predict(TEXT, N_WORDS, temperature=0.75) \n",
" for _ in range(N_SENTENCES)]"
]
},
{
Expand Down Expand Up @@ -1891,7 +1892,8 @@
"metadata": {},
"outputs": [],
"source": [
"learn = text_classifier_learner(dls_clas, AWD_LSTM, drop_mult=0.5, metrics=accuracy).to_fp16()"
"learn = text_classifier_learner(dls_clas, AWD_LSTM, drop_mult=0.5, \n",
" metrics=accuracy).to_fp16()"
]
},
{
Expand Down Expand Up @@ -2260,20 +2262,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.7.5"
},
"toc": {
"base_numbering": 1,
"nav_menu": {},
"number_sections": false,
"sideBar": true,
"skip_h1_title": true,
"title_cell": "Table of Contents",
"title_sidebar": "Contents",
"toc_cell": false,
"toc_position": {},
"toc_section_display": true,
"toc_window_display": false
"version": "3.7.4"
}
},
"nbformat": 4,
Expand Down
24 changes: 7 additions & 17 deletions 11_midlevel_data.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -602,7 +602,8 @@
"source": [
"cut = int(len(files)*0.8)\n",
"splits = [list(range(cut)), list(range(cut,len(files)))]\n",
"tls = TfmdLists(files, [Tokenizer.from_folder(path), Numericalize], splits=splits)"
"tls = TfmdLists(files, [Tokenizer.from_folder(path), Numericalize], \n",
" splits=splits)"
]
},
{
Expand Down Expand Up @@ -1083,7 +1084,8 @@
"class SiameseTransform(Transform):\n",
" def __init__(self, files, label_func, splits):\n",
" self.labels = files.map(label_func).unique()\n",
" self.lbl2files = {l: L(f for f in files if label_func(f) == l) for l in self.labels}\n",
" self.lbl2files = {l: L(f for f in files if label_func(f) == l) \n",
" for l in self.labels}\n",
" self.label_func = label_func\n",
" self.valid = {f: self._draw(f) for f in files[splits[1]]}\n",
" \n",
Expand All @@ -1095,7 +1097,8 @@
" def _draw(self, f):\n",
" same = random.random() < 0.5\n",
" cls = self.label_func(f)\n",
" if not same: cls = random.choice(L(l for l in self.labels if l != cls)) \n",
" if not same: \n",
" cls = random.choice(L(l for l in self.labels if l != cls)) \n",
" return random.choice(self.lbl2files[cls]),same"
]
},
Expand Down Expand Up @@ -1246,20 +1249,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.7.5"
},
"toc": {
"base_numbering": 1,
"nav_menu": {},
"number_sections": false,
"sideBar": true,
"skip_h1_title": true,
"title_cell": "Table of Contents",
"title_sidebar": "Contents",
"toc_cell": false,
"toc_position": {},
"toc_section_display": true,
"toc_window_display": false
"version": "3.7.4"
}
},
"nbformat": 4,
Expand Down
27 changes: 9 additions & 18 deletions 12_nlp_dive.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -497,7 +497,8 @@
}
],
"source": [
"learn = Learner(dls, LMModel1(len(vocab), 64), loss_func=F.cross_entropy, metrics=accuracy)\n",
"learn = Learner(dls, LMModel1(len(vocab), 64), loss_func=F.cross_entropy, \n",
" metrics=accuracy)\n",
"learn.fit_one_cycle(4, 1e-3)"
]
},
Expand Down Expand Up @@ -654,7 +655,8 @@
}
],
"source": [
"learn = Learner(dls, LMModel2(len(vocab), 64), loss_func=F.cross_entropy, metrics=accuracy)\n",
"learn = Learner(dls, LMModel2(len(vocab), 64), loss_func=F.cross_entropy, \n",
" metrics=accuracy)\n",
"learn.fit_one_cycle(4, 1e-3)"
]
},
Expand Down Expand Up @@ -1474,7 +1476,8 @@
}
],
"source": [
"learn = Learner(dls, LMModel5(len(vocab), 64, 2), loss_func=CrossEntropyLossFlat(), \n",
"learn = Learner(dls, LMModel5(len(vocab), 64, 2), \n",
" loss_func=CrossEntropyLossFlat(), \n",
" metrics=accuracy, cbs=ModelReseter)\n",
"learn.fit_one_cycle(15, 3e-3)"
]
Expand Down Expand Up @@ -1867,7 +1870,8 @@
}
],
"source": [
"learn = Learner(dls, LMModel6(len(vocab), 64, 2), loss_func=CrossEntropyLossFlat(), \n",
"learn = Learner(dls, LMModel6(len(vocab), 64, 2), \n",
" loss_func=CrossEntropyLossFlat(), \n",
" metrics=accuracy, cbs=ModelReseter)\n",
"learn.fit_one_cycle(15, 1e-2)"
]
Expand Down Expand Up @@ -2354,20 +2358,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.7.5"
},
"toc": {
"base_numbering": 1,
"nav_menu": {},
"number_sections": false,
"sideBar": true,
"skip_h1_title": true,
"title_cell": "Table of Contents",
"title_sidebar": "Contents",
"toc_cell": false,
"toc_position": {},
"toc_section_display": true,
"toc_window_display": false
"version": "3.7.4"
}
},
"nbformat": 4,
Expand Down
12 changes: 12 additions & 0 deletions 13_convolutions.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -3757,6 +3757,18 @@
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.7.4"
}
},
"nbformat": 4,
Expand Down
Loading

0 comments on commit b2f1c12

Please sign in to comment.