从wwpal兔守护模式获取结果


getting result from Vowpal Wabbit daemon mode

我在守护模式下运行VW。作为一个独立的可执行文件,它运行得非常好。在守护模式下,我最初看到一些关于预测和选项的东西,但不是最终结果。不知道到底发生了什么。

这就是我如何调用VW6

/bin64/vw --daemon --num_children 2 -t -i ~/modelbow.vw6 --min_prediction 0 --max_prediction 1 -p stdout  2>&1 

我检查vw6运行良好。我使用简单的php脚本发送数据(为了简洁删除了调试行):

     $fp = fsockopen("localhost",26542, $errno, $errstr, 3);
     $fp_dat = fopen("/tmp/ml.dat", "r");
     $mldata = explode("'n", file_get_contents("/tmp/ml.dat"));
     $mlstr = implode($mldata);
     fwrite($fp, $mlstr);
     $result = trim(fgets($fp, 1024));
     print $result;

Print $result上面什么也不打印。我在stdout中看到的唯一东西是

num sources = 1
Num weight bits = 28
learning rate = 10
initial_t = 1
power_t = 0.5
decay_learning_rate = 1
predictions = stdout
only testing
average    since       example  example    current  current  current
loss       last        counter   weight      label  predict features

在独立可执行模式下,如果我使用相同的模型相同的数据文件运行,只是没有-daemon选项,它会在最后给出一个结果

...
...
predictions = stdout
only testing
average    since       example  example    current  current  current
loss       last        counter   weight      label  predict features
1.000000 ba66dfc7a135e2728d08010b40586b90

你知道守护模式有什么问题吗?我也试过使用-p/tmp/option…用sudo运行守护模式,但是没有任何帮助。是否有调试转储选项或详细选项或其他选项来了解究竟发生了什么?

谢谢

不工作的原因不是在vw,而是在PHP客户端代码。

explode在"'n"上,去掉换行符。

implode不带glue-string参数,则glue-string默认为空字符串。

结果:去掉换行符。所有的例子被合并成一个大的(不完整的,因为没有换行符在末尾)的例子。

vw需要换行符来分隔示例,如果没有它们,它将永远等待第一个示例完成。

所以我认为你需要改变内爆行代码为:

$mlstr = implode("'n", $mldata);

让它工作

您还需要一个额外的结束换行符来完成最后一行。