AI and Machine Learning for Coders

Errata for AI and Machine Learning for Coders

Submit your own errata for this product.

The errata list is a list of errors and their corrections that were found after the product was released. If the error was corrected in a later version or reprint the date of the correction will be displayed in the column titled "Date Corrected".

The following errata were submitted by our customers and approved as valid errors by the author or editor.

Color key: Serious technical mistake Minor technical mistake Language or formatting error Typo Question Note Update

Version Location Description Submitted By Date submitted Date corrected
Page Ch. 3
transfer learning cats and dogs code

# Flatten the output layer to 1 dimension

x = layers.Flatten()(last_output)

NameError: name 'layers' is not defined

Note from the Author or Editor:
Please change the code on page 56.

Presently the first line reads:
from tensorflow.keras.applications.inception_v3 import InceptionV3

Please edit this to:
from tensorflow.keras.preprocessing.image import ImageDataGenerator
from tensorflow.keras import layers
from tensorflow.keras import Model
from tensorflow.keras.applications.inception_v3 import InceptionV3
from tensorflow.keras.optimizers import RMSprop

Tony Holdroyd  Nov 16, 2020  May 28, 2021
Page 31
In example code

There is an extra unnecessary tab after tf.keras.layers.Dense(10, activation=tf.nn.softmax).

Additionally, tf.keras.datasets.fashion_mnist is assigned to variable mnist, when it was previously assigned to variable data on page 26 and is again later on page 37.

Note from the Author or Editor:
For the tab, please edit the line on page 31 that reads

"tf.keras.layers.Dense(10, activation=tf.nn.softmax)"

It should be de-dented so that it vertically lines up with the line above it.

The other issue, with variable naming is ok as-is.

Matthieu J. Miossec  Jan 18, 2021  May 28, 2021
Page 44
1st paragragh

This paragraph is an exact copy of the last paragraph on page 43, including the code.

Note from the Author or Editor:
The sentence beginning with "Here's the code..", and the code at the bottom of page 43 should be deleted.

The sentence beginning with "Here's the code.." on page 44 should be edited so that the end of the sentence, instead of reading "as shown in the figure" should be "as shown in Figure 3-8."

Anonymous  Apr 17, 2021  May 28, 2021
Page 47
code, top of the page

Perhaps writing out tf.keras.optimizers.RMSprop(lr=0.001) in the code would be helpful to complete beginners.

Note from the Author or Editor:
Can we please make a tip section:

"The code on this page, and in many places in this book may require you to import python libraries. To find the correct imports, you can check out the repo at"

Matthieu J. Miossec  Jan 19, 2021  May 28, 2021