From facf6dfc25e2fc5feec096d853c7f85a095fecc0 Mon Sep 17 00:00:00 2001 From: wangchunlin Date: Sun, 30 Jun 2024 17:21:09 +0800 Subject: [PATCH] =?UTF-8?q?=E5=9B=BE=E7=89=87=E6=89=93=E5=8D=B0=E5=8A=A0?= =?UTF-8?q?=E4=B8=8A=E4=B8=AD=E6=96=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- utils/common.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/utils/common.py b/utils/common.py index e09ea3e..44051b6 100644 --- a/utils/common.py +++ b/utils/common.py @@ -14,6 +14,10 @@ import matplotlib.pyplot as plt # 控制是否打印的宏定义 PRINT_LOG = True +# 确保 matplotlib 支持中文 +plt.rcParams['font.sans-serif'] = ['SimHei'] # 使用黑体 +plt.rcParams['axes.unicode_minus'] = False # 解决保存图像时负号 '-' 显示为方块的问题 + def log_print(message): logging.info(message) if PRINT_LOG: @@ -181,11 +185,11 @@ class MLModel: fig, (ax1, ax2, ax3) = plt.subplots(1, 3, figsize=(15, 5)) ax1.plot(train_loss_history, label='Train Loss(训练损失)') ax1.plot(val_loss_history, label='Validation Loss(验证损失)') - ax1.set_title('Loss') + ax1.set_title('Loss(损失)') ax1.legend() ax2.plot(train_acc_history, label='Train Accuracy(训练正确率)') ax2.plot(val_acc_history, label='Validation Accuracy(验证正确率)') - ax2.set_title('Accuracy') + ax2.set_title('Accuracy(正确率)') ax2.legend() ax3.plot(val_f1_history, label='Validation F1(验证F1得分)') ax3.plot(val_precision_history, label='Validation Precision(验证精确率)')