- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在使用 Caffe 训练神经网络。在 solver.prototxt
文件中,我可以设置 average_loss
来打印最后 N 次迭代的平均损失。是否也可以使用其他值来做到这一点?
例如,我编写了一个自定义的 PythonLayer 输出精度,并且我还想显示最近 N 次迭代的平均精度。
谢谢
编辑:这是日志。 DEBUG
行显示每个图像计算的准确度,每 3 个图像(average_loss: 3
和 display: 3
)显示准确度与损失。我们看到只显示了最后一个,我想要的是3)的平均值。
2018-04-24 10:38:06,383 [DEBUG]: Accuracy: 0 / 524288 = 0.000000
I0424 10:38:07.517436 99964 solver.cpp:251] Iteration 0, loss = 1.84883e+06
I0424 10:38:07.517503 99964 solver.cpp:267] Train net output #0: accuracy = 0
I0424 10:38:07.517521 99964 solver.cpp:267] Train net output #1: loss = 1.84883e+06 (* 1 = 1.84883e+06 loss)
I0424 10:38:07.517536 99964 sgd_solver.cpp:106] Iteration 0, lr = 2e-12
I0424 10:38:07.524904 99964 solver.cpp:287] Time: 2.44301s/1iters
2018-04-24 10:38:08,653 [DEBUG]: Accuracy: 28569 / 524288 = 0.054491
2018-04-24 10:38:11,010 [DEBUG]: Accuracy: 22219 / 524288 = 0.042379
2018-04-24 10:38:13,326 [DEBUG]: Accuracy: 168424 / 524288 = 0.321243
I0424 10:38:14.533329 99964 solver.cpp:251] Iteration 3, loss = 1.84855e+06
I0424 10:38:14.533406 99964 solver.cpp:267] Train net output #0: accuracy = 0.321243
I0424 10:38:14.533426 99964 solver.cpp:267] Train net output #1: loss = 1.84833e+06 (* 1 = 1.84833e+06 loss)
I0424 10:38:14.533440 99964 sgd_solver.cpp:106] Iteration 3, lr = 2e-12
I0424 10:38:14.534195 99964 solver.cpp:287] Time: 7.01088s/3iters
2018-04-24 10:38:15,665 [DEBUG]: Accuracy: 219089 / 524288 = 0.417879
2018-04-24 10:38:17,943 [DEBUG]: Accuracy: 202896 / 524288 = 0.386993
2018-04-24 10:38:20,210 [DEBUG]: Accuracy: 0 / 524288 = 0.000000
I0424 10:38:21.393121 99964 solver.cpp:251] Iteration 6, loss = 1.84769e+06
I0424 10:38:21.393190 99964 solver.cpp:267] Train net output #0: accuracy = 0
I0424 10:38:21.393210 99964 solver.cpp:267] Train net output #1: loss = 1.84816e+06 (* 1 = 1.84816e+06 loss)
I0424 10:38:21.393224 99964 sgd_solver.cpp:106] Iteration 6, lr = 2e-12
I0424 10:38:21.393940 99964 solver.cpp:287] Time: 6.85962s/3iters
2018-04-24 10:38:22,529 [DEBUG]: Accuracy: 161180 / 524288 = 0.307426
2018-04-24 10:38:24,801 [DEBUG]: Accuracy: 178021 / 524288 = 0.339548
2018-04-24 10:38:27,090 [DEBUG]: Accuracy: 208571 / 524288 = 0.397818
I0424 10:38:28.297776 99964 solver.cpp:251] Iteration 9, loss = 1.84482e+06
I0424 10:38:28.297843 99964 solver.cpp:267] Train net output #0: accuracy = 0.397818
I0424 10:38:28.297863 99964 solver.cpp:267] Train net output #1: loss = 1.84361e+06 (* 1 = 1.84361e+06 loss)
I0424 10:38:28.297878 99964 sgd_solver.cpp:106] Iteration 9, lr = 2e-12
I0424 10:38:28.298607 99964 solver.cpp:287] Time: 6.9049s/3iters
I0424 10:38:28.331749 99964 solver.cpp:506] Snapshotting to binary proto file snapshot/train_iter_10.caffemodel
I0424 10:38:36.171842 99964 sgd_solver.cpp:273] Snapshotting solver state to binary proto file snapshot/train_iter_10.solverstate
I0424 10:38:43.068686 99964 solver.cpp:362] Optimization Done.
最佳答案
Caffe 仅在 average_loss
迭代中平均网络的全局损失(所有损失层的加权和),同时报告所有其他输出 blob 的最后一批的输出。
因此,如果您希望 Python 图层报告多次迭代的平均精度,我建议您将缓冲区 SS 存储为图层类的成员,并显示此聚合值。
或者,您可以在准确度计算的基础上实现“移动平均值”,并将该值输出为“顶部”。
您可以在 python 中实现“移动平均输出层”。该层可以采用任意数量的“底部”并输出这些底部的移动平均值。
层的Python代码:
import caffe
class MovingAverageLayer(caffe.Layer):
def setup(self, bottom, top):
assert len(bottom) == len(top), "layer must have same number of inputs and outputs"
# average over how many iterations? read from param_str
self.buf_size = int(self.param_str)
# allocate a buffer for each "bottom"
self.buf = [[] for _ in self.bottom]
def reshape(self, bottom, top):
# make sure inputs and outputs have the same size
for i, b in enumerate(bottom):
top[i].reshape(*b.shape)
def forward(self, bottom, top):
# put into buffers
for i, b in enumerate(bottom):
self.buf[i].append(b.data.copy())
if len(self.buf[i]) > self.buf_size:
self.buf[i].pop(0)
# compute average
a = 0
for elem in self.buf[i]:
a += elem
top[i].data[...] = a / len(self.buf[i])
def backward(self, top, propagate_down, bottom):
# this layer does not back prop
pass
如何在prototxt中使用该层:
layer {
name: "moving_ave"
type: "Python"
bottom: "accuracy"
top: "av_accuracy"
python_param {
layer: "MovingAverageLayer"
module: "path.to.module"
param_str: "30" # buf size
}
}
参见this tutorial了解更多信息。
<小时/>原始错误答案:
Caffe 输出以记录任何净输出:损失、准确性或任何其他出现在层的“顶部”且不用作任何其他层中的“底部”的 Blob 。< br/>因此,如果您想查看 "Python"
层计算的准确度,只需确保没有其他层使用此准确度作为输入即可。
关于machine-learning - Caffe - 其他 N 个最后迭代的平均准确度,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49984211/
我在 MySQL 中有以下数据,我想求和(总计)然后除以行数。 例子: 我想对 AcctSessionTime 列中的所有数字求和并将其除以项目数,所以在我们的例子中 6+4+3+31=44 将它们除
我试图找出一个值在列中出现的平均次数,根据另一列对其进行分组,然后对其进行计算。 我有 3 张 table ,有点像这样 DVD ID | NAME 1 | 1 2 | 1 3
好吧,我完全被困在这里,如果这给你们带来任何不便,我深表歉意,但我需要你们的帮助。 我目前正在自学 C,并且从昨天开始慢慢地达到目标。所以我想给自己一个任务,让用户输入 3 个数字,程序必须找到这三个
我在使用 subAverage 类时遇到困难。当我使用 main 方法时,它似乎无法正常运行。基本上,subAverage 对数组中包含开始索引和结束索引的项进行平均。但是,当我运行它时,我得到了 3
像这样平均一个表不是问题 table = [[1,2,3,0],[1,2,3,0],[1,2,3,4]] 你可以 print numpy.average(table,axis=0) 但是如果我有不均匀
问题 -开发一个类平均脚本,每次运行时都会处理任意数量的结果。提示用户输入每个结果,直到他/她输入 -1。 (哨兵)确定类(class)平均值并将其写入页面。如果未输入结果(第一个输入为 -1),则显
我有 2 个包含以下数据的数组: Array1 = [A, A, A, A, B, B, B, C, C, C, C, C]; Array2 = [4, 2, 4, 6, 3, 9, 6, 5,
我有一个如下所示的文本文件: Mike 5 7 9 Terry 3 7 4 Ste 8 2 3 我写了下面的程序 从文本文件中检索数据 将文本分成由空格分隔的列 将每个名字后面的分数按顺序排序(最低在
我试图找到范围内数字的平均值(即找到 1-1000 范围内所有数字的平均值)。我编写了以下代码来执行此操作,但由于 if 语句,在运行时,代码会生成多个数字。然后我尝试使用 while-loop 代替
我有一系列事件。 1 是好的,0 是坏的。寻找寻找 1 个序列的最大、最小和平均长度的最 Pythonic 方式。 例如: seq ="00100000000000110100100000000011
我有一个包含类似于以下数据的表格: Group TimePoint Value 1 0 1 1 0 2
假设我有一个类 C,它具有属性 a。 从 Python 中的 C 列表中获取 a 总和的最佳方法是什么? 我已经尝试了以下代码,但我知道这不是正确的做法: for c in c_list: t
我有一个看起来像的数据: AAA_1 AAA_2 AAA_3 BBB_1 BBB_2 BBB_3 CCC 1 1 1 1 2 2
对于分色算法,我需要对 std::vector 中的颜色值 (QRgb) 进行平均。 您建议如何做?分别对 3 个分量求和然后取平均值?不然呢? 最佳答案 自 QRgb只是一个 ARGB 格式的 32
在this问题中,我要求对精度调用曲线进行澄清。 特别是,我问我们是否必须考虑一定数量的排名才能画出曲线,还是我们可以合理地选择自己。根据answer,第二个是正确的。 但是,现在我对平均精度(AP)
我想在 UDP 数据包丢失(或丢失)问题上获得其他 SO'ers 的经验。 最初我的理解是,给定直接点对点连接,其中网卡通过交叉电缆连接,网卡上有充足的缓冲区并及时处理所述缓冲区,“应该”没有数据包丢
我有一系列数据,这些数据是通过分子动力学模拟获得的,因此在时间上是连续的,并且在某种程度上是相关的。我可以将平均值计算为数据的平均值,我想估计与以这种方式计算的平均值相关的误差。 根据 this bo
我正在使用以下averageIf公式 =AVERAGEIF('Backend Data - Aerospace'!D:D, "Total",'Backend Data - Aerospace'!E:E
我想列出所有收入超过平均工资的员工。我对此有点迷茫。我需要将所有薪水加起来然后取平均,只显示收入高于平均水平的薪水。在这方面我需要很多帮助。 我的查询不起作用 SQL> select empno,
我正在运行一些音频压缩测试并尝试 Skype's Silk .在他们的测试应用程序中,我看到压缩率为 94%。这似乎很高,这是 Silk 的典型比率吗?这与其他音频压缩编解码器有可比性吗? 最佳答案
我是一名优秀的程序员,十分优秀!