Skip to content

Commit 3ff1ea9

Browse files
committed
Update for new version of tensorflow
1 parent ef07750 commit 3ff1ea9

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

source-code/keras/mnist_utils.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ def create_input_pipeline():
1919
def create_output_pipeline():
2020
output_reshaper = FunctionTransformer(lambda x: x.reshape(-1, 1),
2121
validate=False)
22-
output_encoder = OneHotEncoder(categories='auto')
22+
output_encoder = OneHotEncoder(sparse_output=True, categories='auto')
2323
output_type_changer = FunctionTransformer(lambda x: x.astype(np.float32),
2424
validate=False)
2525
return Pipeline([
@@ -39,8 +39,8 @@ def plot_history(network_history):
3939
plt.figure()
4040
plt.xlabel('Epochs')
4141
plt.ylabel('Accuracy')
42-
plt.plot(network_history.history['acc'])
43-
plt.plot(network_history.history['val_acc'])
42+
plt.plot(network_history.history['accuracy'])
43+
plt.plot(network_history.history['val_accuracy'])
4444
plt.legend(['Training', 'Validation'], loc='lower right')
4545

4646

@@ -49,7 +49,7 @@ def plot_confusion_matrix(cm, classes,
4949
cmap=plt.cm.Blues):
5050
log1p_cm = np.log1p(cm)
5151
if normalize:
52-
cm = cm.astype(np.float)/cm.sum(axis=1)[:, np.newaxis]
52+
cm = cm.astype(np.float32)/cm.sum(axis=1)[:, np.newaxis]
5353
figure, axes = plt.subplots(figsize=(6, 6))
5454
axes.imshow(log1p_cm, interpolation='nearest', cmap=cmap)
5555
axes.set_xticks(classes)

0 commit comments

Comments
 (0)