58690 (6) [Avatar] Offline
#1
Chapter 2: Listing 2.18

import matplotlib.pyplot as pyplot
plt.imshow(digit, cmap=plt.cm.binary)
plt.show()


The import should be
matplotlib.pyplot as plt
(not pylot as the later lines use plt)
58690 (6) [Avatar] Offline
#2
Chapter 3: Listing 3.42

The code is cut off on the listing. It should read:


history = model.fit(partial_x_train, partial_y_train, epochs=20, batch_size=512, validation_data=(x_val,y_val))
58690 (6) [Avatar] Offline
#3
Chapter 3: Listing 3.78

This might be easier to read if some of the variables for the index calculations are lifted like this

k = 4
verbose = 0
batch_size=1
epochs=100
num_val_samples = len(train_data) // k
all_scores = []

for i in range(k):

    print("Processing fold #", i)
    start = i * num_val_samples
    end = (i + 1) * num_val_samples

    # prepare the validation data
    val_data = train_data[start:end]
    val_targets = train_targets[start:end]

    # prepare the traing data
    partial_train_data = np.concatenate([train_data[:start],
                                         train_data[end:]], axis=0)
    partial_train_targets = np.concatenate([train_targets[:start],
                                            train_targets[end:]], axis=0)

    model = build_model()
    model.fit(partial_train_data, partial_train_targets,
              epochs=epochs, batch_size=batch_size, verbose=verbose)
    val_mse, val_mae = model.evaluate(val_data, val_targets, verbose=verbose)
    all_scores.append(val_mae)
58690 (6) [Avatar] Offline
#4
Chapter 3: Listing 3.80

mae_history has the wrong key for history.history. It reads val_mean_absolute error. It should be mean_absolute_error.

    mae_history = history.history["mean_absolute_error"]
58690 (6) [Avatar] Offline
#5
Chapter 3 - Listing 3.82

Code is missing final show line

plt.show()
451719 (1) [Avatar] Offline
#6
Chapter One
[ 956 bytes ]
Listing 2.4 is giving me errors from the import statements. I also noticed that the Dense class does not have the same parameters as the Dense class in the book. Also on lisiting 2.5, network.compile has no metrics argument. I am really worried because my code keeps on breaking
58690 (6) [Avatar] Offline
#7
You may need to update your Keras version. I am using Keras==2.0.3
30904 (2) [Avatar] Offline
#8
On page 153, listing 5.31


model.compile(loss='binary_crossentropy',
optimizer=RMSprop(lr=1e-4),
metrics=['acc'])

produces an error. To resolve the error, I changed this passage to read:


model.compile(loss='binary_crossentropy',
optimizer=optimizers.RMSprop(lr=1e-4),
metrics=['acc'])
408002 (1) [Avatar] Offline
#9
Chapter 2: listing 2.18

plt.imshow(digit, cmap=plt.cm.binary)

does not work on Windows machine