如何在Python中创建特定的打印fn,将输出打印到tkinter GUI而不是终端?

时间:2018-03-18 15:02:44

标签: python numpy user-interface tensorflow keras

我在Python中有以下部分代码:

model.summary()

model.compile(loss='categorical_crossentropy', optimizer=optim, metrics=['accuracy'])
history = model.fit(x_train, y_train_onehot, batch_size=b_size, epochs=epoch, verbose=1, validation_split=0.2)
score = model.evaluate(x_test, y_test_onehot)

print("score: ",score[0])
print("accuracy: ",score[1])

y_pred = model.predict(x_test)
failed_pred = np.where((np.argmax(y_pred, axis=1) != 
np.argmax(y_test_onehot, axis=1)))
print("failed_pred")

x_test_prim = x_test[index]
print("x_test_prim.shape: ",x_test_prim.shape)

img_usable = np.expand_dims(x_test_prim, axis=0)
img_to_show = np.reshape(x_test_prim, (28,28))
plt.imshow(img_to_show)
print(img_usable.shape)
pred_prim = model.predict_classes(img_usable)
print("The prediction: ",pred_prim)
print("The reality: ",y_test[index])

如何在tkinter GUI中打印每个打印fn? 有没有办法在未来的程序中调用这个fn?

0 个答案:

没有答案