TaoTermCreateL1#
Create a TaoTerm for the objective function term \(\|x - p\|_1\).
Synopsis#
#include "petsctao.h"
PetscErrorCode TaoTermCreateL1(MPI_Comm comm, PetscInt n, PetscInt N, PetscReal epsilon, TaoTerm *term)
Collective
Input Parameters#
comm - the MPI communicator where the term will be computed
n - the local size of the \(x\) and \(p\) vectors (or
PETSC_DECIDE)N - the global size of the \(x\) and \(p\) vectors (or
PETSC_DECIDE)epsilon - a non-negative smoothing parameter (see
TaoTermL1SetEpsilon())
Output Parameter#
term - the
TaoTerm
Note#
If you would like to add an L1 regularization term \(\alpha \|x\|_1\) to the objective function of a Tao, do the following:
VecGetLocalSize(x, &n);
VecGetSize(x, &N);
TaoTermCreateL1(PetscObjectComm((PetscObject)x), n, N, 0.0, &term);
TaoAddTerm(tao, "reg_", alpha, term, NULL, NULL);
TaoTermDestroy(&term);
If you would like to have a dictionary matrix term \(\alpha \|D x\|_1\), do the same but pass D as the map of the term:
MatGetLocalSize(D, &m, NULL);
MatGetSize(D, &M, NULL);
TaoTermCreateL1(PetscObjectComm((PetscObject)D), m, M, 0.0, &term);
TaoAddTerm(tao, "reg_", alpha, term, NULL, D);
TaoTermDestroy(&term);
See Also#
TaoTerm: composable objective function terms,
TaoTerm,
TAOTERML1,
TaoTermL1GetEpsilon(),
TaoTermL1SetEpsilon(),
TaoTermCreateHalfL2Squared(),
TaoTermCreateQuadratic()
Level#
beginner
Location#
Examples#
src/tao/unconstrained/tutorials/elastic_net_regularization.c
Index of all TaoTerm routines
Table of Contents for all manual pages
Index of all manual pages