2013-09-26 88 views
1

我正在训练使用vowpal wabbit的模型并注意到一些非常奇怪的事情。在培训期间,报告的平均损失非常低,约为0.06。但是我注意到,当我让模型预测相同训练数据上的标签时,平均损失在〜0.66附近很高,即使是训练数据,模型预测标签的效果也很差。我最初的猜想是模型遭受了很大的偏见,因此我增加了模型的复杂性,以便在第一层使用300个隐藏节点,但问题依然存在。当被要求预测训练集但训练较低时的平均损失时,训练集上的高错误

我将不胜感激什么可以在

教程幻灯片VW被去指针提到: “如果你在火车上组测试,它的工作原理(无 =>一些疯狂的)?”

因此,一些非常疯狂的事情似乎正在发生,我试图理解我应该更深入挖掘的可能性。

更多详细信息: 我正在使用vowpal wabbit进行命名实体识别任务,其中特征是词表示。我正在尝试使用具有多个隐藏单元的神经网络并试图评估模型的几个模型。然而,当我在训练数据本身上进行测试时,我所有训练有素的模型都表现出很高的平均损失,这些我觉得很奇怪

这里是重现该问题的一种方法:

的训练输出:

vw -d ~/embeddings/eng_train_4.vw --loss_function logistic --oaa 6 --nn 32 -l 10 --random_weights 1 -f test_3.model --passes 4 -c 

final_regressor = test_3.model 
Num weight bits = 18 
learning rate = 10 
initial_t = 0 
power_t = 0.5 
decay_learning_rate = 1 
using cache_file = /home/vvkulkarni/embeddings/eng_train_4.vw.cache 
ignoring text input in favor of cache input 
num sources = 1 
average since   example  example current current current 
loss  last   counter  weight label predict features 
0.666667 0.666667   3  3.0   1  1  577 
0.833333 1.000000   6  6.0   1  2  577 
0.818182 0.800000   11  11.0   4  4  577 
0.863636 0.909091   22  22.0   1  4  577 
0.636364 0.409091   44  44.0   1  1  577 
0.390805 0.139535   87  87.0   1  1  577 
0.258621 0.126437  174 174.0   1  1  577 
0.160920 0.063218  348 348.0   1  1  577 
0.145115 0.129310  696 696.0   1  1  577 
0.138649 0.132184  1392 1392.0   1  1  577 
0.122486 0.106322  2784 2784.0   1  1  577 
0.097522 0.072557  5568 5568.0   1  1  577 
0.076875 0.056224  11135 11135.0   1  1  577 
0.058647 0.040417  22269 22269.0   1  1  577 
0.047803 0.036959  44537 44537.0   1  1  577 
0.038934 0.030066  89073 89073.0   1  1  577 
0.036768 0.034601  178146 178146.0   1  1  577 
0.032410 0.032410  356291 356291.0   1  1  577 h 
0.029782 0.027155  712582 712582.0   1  1  577 h 

finished run 
number of examples per pass = 183259 
passes used = 4 
weighted example sum = 733036 
weighted label sum = 0 
average loss = 0.0276999 
best constant = 0 
total feature number = 422961744 

现在,当我评价以上利用相同的数据模型(用于训练)

vw -t ~/embeddings/eng_train_4.vw -i test_3.model -p test_3.pred 

only testing 
Num weight bits = 18 
learning rate = 10 
initial_t = 1 
power_t = 0.5 
predictions = test_3.pred 
using no cache 
Reading datafile = /home/vvkulkarni/embeddings/eng_train_4.vw 
num sources = 1 
average since   example  example current current current 
loss  last   counter  weight label predict features 
0.333333 0.333333   3  3.0   1  1  577 
0.500000 0.666667   6  6.0   1  4  577 
0.636364 0.800000   11  11.0   6  3  577 
0.590909 0.545455   22  22.0   1  1  577 
0.500000 0.409091   44  44.0   4  1  577 
0.482759 0.465116   87  87.0   1  1  577 
0.528736 0.574713  174 174.0   1  3  577 
0.500000 0.471264  348 348.0   1  3  577 
0.517241 0.534483  696 696.0   6  1  577 
0.536638 0.556034  1392 1392.0   4  4  577 
0.560345 0.584052  2784 2784.0   1  5  577 
0.560884 0.561422  5568 5568.0   6  2  577 
0.586349 0.611820  11135 11135.0   1  1  577 
0.560914 0.535477  22269 22269.0   1  1  577 
0.557200 0.553485  44537 44537.0   1  1  577 
0.568938 0.580676  89073 89073.0   1  2  577 
0.560568 0.552199  178146 178146.0   1  1  577 

finished run 
number of examples per pass = 203621 
passes used = 1 
weighted example sum = 203621 
weighted label sum = 0 
average loss = 0.557428 <<< This is what is tricky. 
best constant = -4.91111e-06 
total feature number = 117489309 

我试过的东西: 1.我试图增加隐藏节点的数量到600,但无济于事。 2.我也尝试使用300个隐藏节点的二次特征,但这也没有帮助。

尝试1.)和2.)背后的基本原理是增加模型复杂性,假设高训练误差是由于高偏差造成的。如果我在测试阶段将通过次数指定为4(即使我假设模型已经学会了决策边界),那么问题就会消失。我想明白为什么?

[email protected]:/scratch1/vivek/test$ vw -t ~/embeddings/eng_train_4.vw -i test_3.model -p test_3_1.pred --passes 4 -c 
only testing 
Num weight bits = 18 
learning rate = 10 
initial_t = 1 
power_t = 0.5 
decay_learning_rate = 1 
predictions = test_3_1.pred 
using cache_file = /home/vvkulkarni/embeddings/eng_train_4.vw.cache 
ignoring text input in favor of cache input 
num sources = 1 
average since   example  example current current current 
loss  last   counter  weight label predict features 
0.333333 0.333333   3  3.0   1  1  577 
0.166667 0.000000   6  6.0   1  1  577 
0.090909 0.000000   11  11.0   4  4  577 
0.045455 0.000000   22  22.0   1  1  577 
0.022727 0.000000   44  44.0   1  1  577 
0.011494 0.000000   87  87.0   1  1  577 
0.017241 0.022989  174 174.0   1  1  577 
0.022989 0.028736  348 348.0   1  1  577 
0.020115 0.017241  696 696.0   1  1  577 
0.043822 0.067529  1392 1392.0   1  1  577 
0.031968 0.020115  2784 2784.0   1  1  577 
0.031968 0.031968  5568 5568.0   1  1  577 
0.032959 0.033950  11135 11135.0   1  1  577 
0.029952 0.026944  22269 22269.0   1  1  577 
0.029212 0.028471  44537 44537.0   1  1  577 
0.030481 0.031750  89073 89073.0   1  1  577 
0.028673 0.026866  178146 178146.0   1  1  577 
0.034001 0.034001  356291 356291.0   1  1  577 h 
0.034026 0.034051  712582 712582.0   1  1  577 h 
+0

你应该包括**更多的**细节。简短,可重复的代码是必需的任何帮助 – lejlot

+0

Thanks.I已添加我使用的模型的细节。还添加了命令行,我和他们的输出一起用来精确地指出问题,也是我尝试过的。请让我知道是否需要任何具体细节。 – vvknitk

+0

你确定你正在测试相同的数据吗?请注意,对于相同的示例编号,两次运行中的“当前标签”是不同的,当我期望它们在相同的数据上相同时。另一个可疑的事情是,即使在为训练集(训练步骤)创建高速缓存之后,测试步骤似乎也不会使用高速缓存... – arielf

回答

1

你有散列冲突,因为你有更多的功能比散列中有空格。

默认散列大小是18位或262144空格。根据您的第一个打印输出,有422961744个功能,至少需要27位,因此您应该在命令行中添加-b27(或更多)。

我没有你的输入文件,所以我不能尝试它,看到..但这里是检查冲突的一种方式:

运行您的学习阶段,并与这些行添加--invert_hash最终 然后检查碰撞:

tail -n +13 final | sort -n -k 2 -t ':' | wc -l 
tail -n +13 final | sort -nu -k 2 -t ':' | wc -l 

值输出应该是相同的。我从Vowpal Wabbit的创建者John Langford那里得到了这个建议。

+1

请注意,422961744是运行期间看到的功能的总数,而不是唯一的功能。所以total/examples/passes = 422961744/183259/4 = 577这正是每个例子的特征数量。所以我不会在这里怀疑碰撞。 – arielf