-
Notifications
You must be signed in to change notification settings - Fork 213
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
05b6cea
commit a7fb32c
Showing
21 changed files
with
117 additions
and
195 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
// | ||
// Created by jiashuai on 17-10-5. | ||
// | ||
#include <iostream> | ||
#include <thundersvm/kernel/kernelmatrix_kernel.h> | ||
#include <thundersvm/solver/csmosolver.h> | ||
#include "thundersvm/model/svr.h" | ||
|
||
void SVR::train(DataSet dataset, SvmParam param) { | ||
int n_instances = dataset.total_count(); | ||
|
||
//duplicate instances | ||
DataSet::node2d instances_2(dataset.instances()); | ||
instances_2.insert(instances_2.end(), dataset.instances().begin(), dataset.instances().end()); | ||
|
||
KernelMatrix kernelMatrix(instances_2, param); | ||
|
||
SyncData<real> f_val(n_instances * 2); | ||
SyncData<int> y(n_instances * 2); | ||
|
||
for (int i = 0; i < n_instances; ++i) { | ||
f_val[i] = param.p - dataset.y()[i]; | ||
y[i] = +1; | ||
f_val[i + n_instances] = -param.p - dataset.y()[i]; | ||
y[i + n_instances] = -1; | ||
} | ||
|
||
SyncData<real> alpha_2(n_instances * 2); | ||
alpha_2.mem_set(0); | ||
int ws_size = min(max2power(n_instances) * 2, 1024); | ||
CSMOSolver solver; | ||
solver.solve(kernelMatrix, y, alpha_2, rho, f_val, param.epsilon, param.C, param.C, ws_size); | ||
SyncData<real> alpha(n_instances); | ||
for (int i = 0; i < n_instances; ++i) { | ||
alpha[i] = alpha_2[i] - alpha_2[i + n_instances]; | ||
} | ||
record_model(alpha, y, dataset.instances(), param); | ||
} | ||
|
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.