如何在C ++ [库模式]中抑制LibSVM的输出

3

当LibSVM从命令行执行时,我可以给出-q作为参数,一切都会没问题。但是,当我将其用作库时,没有-q参数可编程设置。那么我该如何抑制输出呢?在Java和Python中存在解决方案,但在C ++中不存在。

3个回答

2
你可以使用在 svm_train.c 中所用的相同技巧。
  • First define a function that does nothing:

    void print_null(const char *s) {}
    
  • Then call the function that sets the printing:

    svm_set_print_string_function(&print_null);
    

0
svm_set_print_string_function([](auto c) {});

0

LibSVM也可以作为源代码分发。您可以删除所有不需要的fprintf或将输出函数指针信息设置为0。

static int (*info)(const char *fmt,...) = 0;//&printf;

然后重新构建:

nmake -f Makefile.win lib

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接