在 TensorFlow 中,可以使用 matplotlib 库来可视化训练模型的准确度。首先,需要在训练模型时记录准确度的值,然后使用 matplotlib 绘制准确度的曲线图。
下面是一个简单的示例代码:
import matplotlib.pyplot as plt
# 记录准确度的数组
accuracy = []
# 在训练过程中更新 accuracy 数组
for epoch in range(num_epochs):
# 训练代码
accuracy.append(acc)
# 绘制准确度曲线图
plt.plot(range(num_epochs), accuracy)
plt.xlabel('Epochs')
plt.ylabel('Accuracy')
plt.show()