作者名:Sean Saito Yang Wenzhuo Rajalingappaa Shanmugamani
本章字數:255字
更新時間:2021-07-23 19:05:05
Building the network
Multiple deep learning frameworks have already implemented APIs for loading the F-MNIST dataset, including TensorFlow. For our implementation, we will be using Keras, another popular deep learning framework that is integrated with TensorFlow. The Keras datasets module provides a highly convenient interface for loading the datasets as numpy arrays.
Finally, we can start coding! For this exercise, we only need one Python module, which we will call cnn.py. Open up your favorite text editor or IDE, and let's get started.
Our first step is to declare the modules that we are going to use:
import logging import os import sys
logger = logging.getLogger(__name__)
import tensorflow as tf import numpy as np from keras.datasets import fashion_mnist from keras.utils import np_utils
The following describes what each module is for and how we will use it:
We will implement our CNN as a class called SimpleCNN. The __init__ constructor takes a number of parameters:
The parameters our SimpleCNN is initialized with are described here:
Moreover, save_dir and save_path refer to the locations where we will store our network's parameters. logs_dir and logs_path refer to the locations where the statistics of the training run will be stored (we will show how we can retrieve these logs later).