Registered Member
|
Hello,
I have the following snippet where I'm computing the partial derivatives for solving the regularized ridge regression so need to avoid regularizing the first (bias) coefficient: ... + lambda*[0; thetas(2, end)] Basically I create a new column vector by appending zero (first row) with the relevant theta elements, how can I achieve the same using Eigen in the most succinct way? TIA, Best regards, Giovanni |
Moderator
|
... + lambda * (VectorXd(end-1) << 0, thetas.segment(2,end-2)).finish() ...
or create a tmp:
You might also consider thetas.tail(end-2) if you want the last end-2 elements. |
Registered Member
|
Very useful, thank you!
|
Registered users: Bing [Bot], Google [Bot], Sogou [Bot]