Create an algorithm to distinguish dogs from cats
File operations
file_name = os.listdir(train_dir)
print(file_name[:10])
file_name.sort()
len()
Plot
import matplotlib.pyplot as plt
import matplotlib.pyplot as plt
set up a matplotlib fig, the number of subfigures are ncols*nrows
fig = plt.gcf()
fig.set_size_inches(ncols * 4, nrows * 4)
get 8 pictures, first index=0
next_cat_pix = [os.path.join(train_cats_dir, fname)
for fname in train_cat_fnames[pic_index-8:pic_index]]
list can be added together with next_cat_pix+next_dog_pix
show each subplots, enumerate can get the number and contents
for i, img_path in enumerate(next_cat_pix+next_dog_pix):
# Set up subplot; subplot indices start at 1
sp = plt.subplot(nrows, ncols, i + 1)
sp.axis('Off') # Don't show axes (or gridlines)
img = mpimg.imread(img_path)
plt.imshow(img) # won't display figures, just draws a picture
plt.show()
问题
image.png
这是什么意思,和我设置的参数之间的关系是什么,电脑要跑崩了
Feature Extraction Using a Pretrained Model
use the output of the very last layer before the Flatten operation, the so-called "bottleneck layer." The reasoning here is that the following fully connected layers will be too specialized for the task the network was trained on, and thus the features learned by these layers won't be very useful for a new task. The bottleneck features, however, retain much generality.














网友评论