我正在繪制準確性和損失數字。我得到以下圖,代表 0 之后的 3 個位置,如 0.XXX 我的目標是只呈現一個,如 0.X
我怎樣才能解決這個問題
acc = history.history['accuracy']
acc_val = history.history['val_accuracy']
epochs = range(len(acc))
plt.title('Training and Validation accuracy')
plt.xlabel('Epochs')
plt.ylabel('accuracy')
plt.legend()
plt.show()
準確率
uj5u.com熱心網友回復:
試試下面的:
import matplotlib.pyplot as plt
from matplotlib.ticker import FormatStrFormatter
acc = history.history['accuracy']
fig, ax = plt.subplots()
plt.plot([i for i in range(len(acc))], acc)
ax.yaxis.set_major_formatter(FormatStrFormatter('%.1f'))
plt.show()
但是您可能會看到多個具有相同值的刻度。或者或此外,您可以使用以下內容將刻度限制為您想要顯示的內容:
ax.set_yticks([0.8, 0.9, 1.0])
轉載請註明出處,本文鏈接:https://www.uj5u.com/caozuo/367142.html
標籤:Python matplotlib 阴谋
上一篇:如何更改折線圖一個資料點的顏色
