Esempio n. 1
0
File: l2.hpp Progetto: 0x0all/madlib
void
L2<Model, Hessian>::hessian(
        const model_type                    &model,
        const double                        &lambda, 
        hessian_type                        &hessian) 
{
    int n = model.rows();
    hessian += lambda * hessian.Identity(n, n);
    hessian(n-1, n-1) -= lambda;
}
Esempio n. 2
0
File: l2.hpp Progetto: 0x0all/madlib
void
L2<Model, Hessian>::gradient(
        const model_type                    &model,
        const double                        &lambda, 
        model_type                          &gradient) 
{
    Index i;
    for (i = 0; i < model.rows()-1; i++)
        gradient(i) += lambda * model(i);
}
Esempio n. 3
0
File: l2.hpp Progetto: 0x0all/madlib
double 
L2<Model, Hessian>::loss(
        const model_type                    &model, 
        const double                        &lambda) 
{
    Index i;
    double s = 0.;
    for (i = 0; i < model.rows()-1; i++)
        s += model(i) * model(i);
    return lambda * s / 2.;
}