Exercises

Please go through the following exercises and answer all questions carefully. This is the only way (by making exercises, via trial and error, and with a lot of struggle) you will be able to master the framework and become an expert:

  1. Define a classifier using the Sequential, Functional, and Subclassing APIs so that you can classify the fashion-MNIST dataset.
  2. Train the model using the Keras model's built-in methods and measure the prediction accuracy.
  3. Write a class that accepts a Keras model in its constructor and that it trains and evaluates. The API should work as follows:
# Define your modeltrainer = Trainer(model)# Get features and labels as numpy arrays (explore the dataset available in the keras module)trainer.train(features, ...

Get Hands-On Neural Networks with TensorFlow 2.0 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.