template<typename math_t>
class ML::SVM::WorkingSet< math_t >
Working set selection for the SMO algorithm.
The working set is a subset of the training vectors, by default it has 1024 elements. At every outer iteration in SmoSolver::Solve, we select a different working set, and optimize the dual coefficients for the working set.
The vectors are selected based on the f values, which is the difference between the target label and the decision function value.
template<typename math_t >
Select elements from the previous working set based on their priority.
We sort the old working set based on their priority in ascending order, and then select nc elements from free, and then lower/upper bound vectors. For details see [2].
See Issue #946.
References: [2] T Serafini, L Zanni: On the Working Set selection in grad. projection based decomposition techniques for Support Vector Machines DOI: 10.1080/10556780500140714
- Parameters
-
[in] | alpha | device vector of dual coefficients, size [n_train] |
[in] | C | penalty parameter |
[in] | nc | number of elements to select |
template<typename math_t >
void ML::SVM::WorkingSet< math_t >::Select |
( |
math_t * |
f, |
|
|
math_t * |
alpha, |
|
|
math_t * |
y, |
|
|
const math_t * |
C |
|
) |
| |
|
inline |
Select working set indices.
To avoid training vectors oscillating in and out of the working set, we keep half of the previous working set, and fill new elements only to the other half.
We can have a FIFO retention policy, or we can consider the time (=ws_priority) a vector already spent in the ws. References: [1] Z. Wen et al. ThunderSVM: A Fast SVM Library on GPUs and CPUs, Journal of Machine Learning Research, 19, 1-5 (2018)
- Parameters
-
f | optimality indicator vector, size [n_train] |
alpha | dual coefficients, size [n_train] |
y | class labels, size [n_train] |
C | penalty parameter vector, size [n_train] |
template<typename math_t >
void ML::SVM::WorkingSet< math_t >::SimpleSelect |
( |
math_t * |
f, |
|
|
math_t * |
alpha, |
|
|
math_t * |
y, |
|
|
const math_t * |
C, |
|
|
int |
n_already_selected = 0 |
|
) |
| |
Select new elements for a working set.
Here we follow the working set selection strategy by Joachims [1], we select n training instances as:
- select n/2 element of upper set, where f is largest
- select n/2 from lower set, where f is smallest
The difference compared to Joachims' strategy is that we can already have some elements selected by a different strategy, therefore we select only n = n_ws - n_already_selected.
References: [1] Joachims, T. (1998). Making large-scale support vector machine learning practical. In B. Scholkopf, C. Burges, & A. Smola (Eds.), Advances in kernel methods: Support vector machines. Cambridge, MA: MIT Press
- Parameters
-
f | optimality indicator vector, size [n_train] |
alpha | dual coefficients, size [n_train] |
y | target labels (+/- 1) |
C | penalty parameter vector size [n_train] |
n_already_selected | |