Skip to content

Commit 15f7035

Browse files
authored
Ch13 figs (rasbt#30)
* Added fig 1 and 2 * Rename image and figure folders * Using os.path.basename * Run all cells
1 parent b337a20 commit 15f7035

File tree

10 files changed

+270
-1364
lines changed

10 files changed

+270
-1364
lines changed
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

Diff for: ch13/ch13_part1.ipynb

+253-1,361
Large diffs are not rendered by default.

Diff for: ch13/ch13_part1.py

+17-3
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import numpy as np
66
import pathlib
77
import matplotlib.pyplot as plt
8+
import os
89
import tensorflow_datasets as tfds
910

1011
# *Python Machine Learning 3rd Edition* by [Sebastian Raschka](https://sebastianraschka.com) & [Vahid Mirjalili](http://vahidmirjalili.com), Packt Publishing Ltd. 2019
@@ -30,8 +31,16 @@
3031

3132
# ### Performance challenges
3233

34+
35+
36+
37+
3338
# ### What is TensorFlow?
3439

40+
41+
42+
43+
3544
# ### How we will learn TensorFlow
3645

3746
# ## First steps with TensorFlow
@@ -361,7 +370,7 @@
361370

362371

363372

364-
imgdir_path = pathlib.Path('images')
373+
imgdir_path = pathlib.Path('cat_dog_images')
365374

366375
file_list = [str(path) for path in imgdir_path.glob('*.jpg')]
367376

@@ -380,7 +389,7 @@
380389
ax = fig.add_subplot(2, 3, i+1)
381390
ax.set_xticks([]); ax.set_yticks([])
382391
ax.imshow(img)
383-
ax.set_title(file, size=15)
392+
ax.set_title(os.path.basename(file), size=15)
384393

385394
# plt.savefig('ch13-catdot-examples.pdf')
386395
plt.tight_layout()
@@ -389,7 +398,7 @@
389398

390399

391400

392-
labels = [1 if 'dog' in file else 0
401+
labels = [1 if 'dog' in os.path.basename(file) else 0
393402
for file in file_list]
394403
print(labels)
395404

@@ -558,3 +567,8 @@ def load_and_preprocess(path, label):
558567

559568

560569

570+
571+
572+
573+
574+

Diff for: ch13/images/01.png

79.8 KB
Loading

Diff for: ch13/images/02.png

88.9 KB
Loading

0 commit comments

Comments
 (0)