博客
关于我
plotloss记录
阅读量:802 次
发布时间:2023-03-02

本文共 633 字,大约阅读时间需要 2 分钟。

数据记录与可视化

为了有效跟踪并分析训练过程中的损失函数值,我们需要将所有损失值记录下来,并对其进行可视化分析。

一、记录损失值

all_loss = []with open('data.txt', 'w') as f:    all_loss.append(loss)    f.write(str(all_loss))    f.close()

二、绘制损失曲线

import matplotlib.pyplot as pltdata = []with open('data.txt', 'r') as f:    for line in f.readlines():        arr = line.split(',')        data.append(arr)# 去除空白部分并转化为浮点数for i in range(len(data)):    data[i] = [float(x) for x in data[i]]    # 设置绘图参数x = [i * 100 for i in range(len(data))]plt.plot(x, data, label="SSD损失曲线")plt.legend()plt.show()

以上代码首先记录训练过程中的损失值到data.txt文件中,然后读取该文件并将其转化为浮点数数组,最后使用Matplotlib库绘制损失曲线。通过这种方式,可以直观地观察SSD损失函数在训练过程中的变化趋势。

转载地址:http://dgtfk.baihongyu.com/

你可能感兴趣的文章
POJ 3041 - 最大二分匹配
查看>>
POJ 3041 Asteroids(二分匹配模板题)
查看>>
Qt笔记——标准文件对话框QFileDialog
查看>>
poj 3083 Children of the Candy Corn
查看>>
POJ 3083 Children of the Candy Corn 解题报告
查看>>
POJ 3253 Fence Repair C++ STL multiset 可解 (同51nod 1117 聪明的木匠)
查看>>
Qt笔记——控件总结
查看>>
poj 3262 Protecting the Flowers 贪心
查看>>
poj 3264(简单线段树)
查看>>
Qt笔记——布局管理三件套分割窗口、停靠窗口和堆栈窗口
查看>>
poj 3277 线段树
查看>>
POJ 3349 Snowflake Snow Snowflakes
查看>>
POJ 3411 DFS
查看>>
poj 3422 Kaka's Matrix Travels (费用流 + 拆点)
查看>>
Qt笔记——官方文档全局定义(二)Functions函数
查看>>
POJ 3468 A Simple Problem with Integers
查看>>
poj 3468 A Simple Problem with Integers 降维线段树
查看>>
poj 3468 A Simple Problem with Integers(线段树 插线问线)
查看>>
poj 3485 区间选点
查看>>
poj 3518 Prime Gap
查看>>