47 #ifndef SHARK_ALGORITHMS_TRAINERS_ABSTRACTSVMTRAINER_H 48 #define SHARK_ALGORITHMS_TRAINERS_ABSTRACTSVMTRAINER_H 75 QpConfig(
bool precomputedFlag =
false,
bool sparsifyFlag =
true)
198 , m_regularizers(1,C)
199 , m_trainOffset(offset)
200 , m_unconstrained(unconstrained)
201 , m_cacheSize(0x4000000)
213 AbstractSvmTrainer(KernelType* kernel,
double negativeC,
double positiveC,
bool offset,
bool unconstrained =
false)
216 , m_trainOffset(offset)
217 , m_unconstrained(unconstrained)
218 , m_cacheSize(0x4000000)
223 m_regularizers[0] = negativeC;
224 m_regularizers[1] = positiveC;
232 return m_regularizers[0];
237 m_regularizers[0] = C;
242 return m_regularizers;
247 SHARK_RUNTIME_CHECK( min(regularizers) > 0,
"regularization parameters must be larger than 0" );
248 m_regularizers = regularizers;
261 {
return m_unconstrained; }
264 {
return m_trainOffset; }
267 {
return m_cacheSize; }
269 { m_cacheSize = size; }
274 return m_kernel->parameterVector() | log(m_regularizers);
276 return m_kernel->parameterVector() | m_regularizers;
281 size_t kp = m_kernel->numberOfParameters();
282 SHARK_ASSERT(newParameters.size() == kp + m_regularizers.size());
283 m_kernel->setParameterVector(subrange(newParameters,0,kp));
284 noalias(m_regularizers) = subrange(newParameters,kp,newParameters.size());
286 m_regularizers = exp(m_regularizers);
291 return m_kernel->numberOfParameters() + m_regularizers.size();
319 template <
class InputType>
335 , m_trainOffset(offset)
336 , m_unconstrained(unconstrained)
351 {
return m_unconstrained; }
354 {
return m_trainOffset; }
360 ret(0) = (m_unconstrained ? std::log(m_C) : m_C);
368 setC(m_unconstrained ? std::exp(newParameters(0)) : newParameters(0));