SVM 训练时间是否取决于输入数据的内容?
Does SVM training time depend on content of input data?
我正在训练SVM(来自openCV的train_auto(两次。
两次我都使用相同的参数: C=0.01,100.000 次迭代,32 个特征和 24550 个样本。 但是不同的输入样本。第一次我只使用我的训练数据,第二次,更少的训练数据 + 一些错误的否定,但训练数据的数量与第一步相同。
第一次训练在大约 2 小时后完成。而第二个运行无休止(超过 10 小时(。这怎么可能,我该如何解决问题?
问候 斯特菲
编辑一些代码:
void SVMtrain(bool retraining) {
int factor_pos = 5;
int factor_neg = 10;
std::string line;
int N_pos = 2474;
N_pos *= factor_pos;
int N_neg = 0;
std::ifstream myfile2(LIST_NEG);
while (std::getline(myfile2, line))
++N_neg;
N_neg *= factor_neg;
Mat points = createFirstSet(N_pos, N_neg, factor_pos, factor_neg);
Mat labels = createFirstLabels(N_pos, N_neg);
Mat all_neg;
if (retraining) {
Mat hardNegatives = find_hardNegatives();
hardNegatives.copyTo(points(Rect(0, points.rows - (MAX_HARD_NEG+1), hardNegatives.cols, hardNegatives.rows)));
}
// Train with SVM
CvSVMParams params;
params.svm_type = CvSVM::C_SVC;
params.kernel_type = CvSVM::LINEAR;
params.C = 0.01; //best option according to Dalal and Triggs
params.term_crit = cvTermCriteria(CV_TERMCRIT_ITER, iterations, 1e-6);
CvSVM SVM;
if (retraining) {
cout << "Training SVM with " << points.rows << " Datapoints... (" << N_pos << ", " << points.rows - N_pos << ") since: " << getTimeFormatted()<< endl;
SVM.train_auto(points, labels, Mat(), Mat(), params);
SVM.save(SVM_2_LOCATION);
}
else {
cout << "Training SVM with " << points.rows << " Datapoints... (" << N_pos << ", " << N_neg << ") since: " << getTimeFormatted() << endl;
SVM.train_auto(points, labels, Mat(), Mat(), params);
SVM.save(SVM_LOCATION);
}
cout << "finished training at " << getTimeFormatted() << endl << endl;
}
这应该是不可能的。
但是你提到,在第二次训练中,你添加了一些假阴性。虽然我不知道你的数据到底是什么样子的,但我假设,这使得数据不是线性可分的。这可能是破坏了您对 SVM 的实现。否则我无法进一步帮助您
相关文章:
- c ++数据输入并读回列表中的结构结构中的数组
- 为什么我不能从结构将数据输入到字符数组中?
- C 如何忽略错误数据输入
- 如何在 C++ 中将结构类型向量数据输入到结构向量成员(嵌套结构向量)中
- 使用 for 循环多次将数据输入到 txt 文件
- C 从文本文件中将数据输入INT矢量
- 将数据输入两个字符串
- 带有 QSqlTableModel 的 QTableView 的数据输入
- C++用户将数据输入 2D 数组的最简单方法是什么?
- C++LinkedList数据输入
- 将数据输入到 2-D 数组中,这是如何工作的
- C++ 将数据输入私有向量时遇到问题(使用无效)
- 使数据输入字段记住其值,从一次运行到下一次运行
- C++ 将数据输入到用户定义类型的向量
- 我不知道如何正确地将数据输入到地图中
- 如何通过输入终止数据输入
- WHILE循环和数据输入
- 不按我的要求显示数据输入表单
- 用键盘将数据输入Qt GUI:按下回车键时会产生意想不到的副作用
- c++为不符合条件的数据输入创建循环