Using the built-in frameworks
We've covered XGBoost and Scikit-Learn already. Now, it's time to see how we can use deep learning frameworks. Let's start with TensorFlow and Keras.
Working with TensorFlow and Keras
In this example, we're going to train a simple convolutional neural network on the Fashion-MNIST dataset (https://github.com/zalandoresearch/fashion-mnist).
Our code is split in two source files: one for the entry point script (fmnist.py
, using only TensorFlow 2.x APIs), and one for the model (model.py
, based on Keras layers). For the sake of brevity, I will only discuss the SageMaker-related steps. You can find the full code in the GitHub repository for this book:
fmnist.py
starts by reading hyperparameters from the command line:import tensorflow as tf import numpy as np import argparse, os from model import FMNISTModel parser = argparse.ArgumentParser()parser.add_argument('--epochs', type=int, default=10)parser.add_argument...