March 2019
Intermediate to advanced
196 pages
4h 50m
English
First, we need to import the dependencies:
import tensorflow as tfimport kerasimport numpy as npfrom sklearn.model_selection import train_test_splitfrom os import walk
You may need to run pip install sklearn. Next, we will establish some constants for later use:
batch_size = 128img_rows, img_cols = 28, 28 # image dimensions
Next, we will use the os.walk method to collect the filenames of datasets from the data_files folder:
data_path = "data_files/" for (dirpath, dirnames, filenames) in walk(data_path): pass # filenames accumulate in list 'filenames'print(filenames)
The filenames (which correspond to the label categories) are as follows for our ...
Read now
Unlock full access