Added total running time. /JL

This commit is contained in:
2019-05-15 20:30:23 +02:00
parent dba4382ab8
commit fd860ac8be
2 changed files with 10 additions and 6 deletions
+5 -3
View File
@@ -44,13 +44,15 @@ print("Training network ...")
model.compile(loss='categorical_crossentropy', optimizer='adam', metrics=['accuracy']) model.compile(loss='categorical_crossentropy', optimizer='adam', metrics=['accuracy'])
print("Making predictions...") print("Making predictions...")
t1 = time.time() t3 = time.time()
for i in range(9): for i in range(9):
img = np.array(X_test[i][np.newaxis,:]) img = np.array(X_test[i][np.newaxis,:])
preds = model.predict_classes(img) preds = model.predict_classes(img)
print("Image[", i, "] - Me thinks me saw a : ", predictions[int(preds[0])] ) print("Image[", i, "] - Me thinks me saw a : ", predictions[int(preds[0])] )
t2 = time.time() t4 = time.time()
print("Predictions took %.2f sec." % (t2 - t1)) print("Predictions took %.2f sec." % (t4 - t3))
print('Total running time %.2f sec' % (t4 - t1))
+5 -3
View File
@@ -70,13 +70,15 @@ with open("mnist.json", "w") as json_file:
model.save_weights('mnist.h5') model.save_weights('mnist.h5')
print("Making predictions...") print("Making predictions...")
t1 = time.time() t3 = time.time()
for i in range(9): for i in range(9):
img = np.array(X_test[i][np.newaxis,:]) img = np.array(X_test[i][np.newaxis,:])
preds = model.predict_classes(img) preds = model.predict_classes(img)
print("Image[", i, "] - Me thinks me saw a : ", predictions[int(preds[0])] ) print("Image[", i, "] - Me thinks me saw a : ", predictions[int(preds[0])] )
t2 = time.time() t4 = time.time()
print("Predictions took %.2f sec." % (t2 - t1)) print("Predictions took %.2f sec." % (t4 - t3))
print('Total running time %.2f sec' % (t4 - t1))