L1Prior

Adds L1 regularization to a Linear layer.

This is implemented as a proximal operator during SGD.

Constructors

this
this(float lambda)
Undocumented in source.
this
this(float lambda, float[][] W_prior_)
Undocumented in source.

Members

Functions

dup
ProxyLinearPrior dup()
Undocumented in source. Be warned that the author may not have intended to support it.
proxy_step
void proxy_step()
Undocumented in source. Be warned that the author may not have intended to support it.
register
void register(Linear layer)
Undocumented in source. Be warned that the author may not have intended to support it.

Mixins

__anonymous
mixin opCallNew
Undocumented in source.

Variables

W_prior
float[][] W_prior;
Undocumented in source.
_ind_start
size_t _ind_start;
Undocumented in source.
_lambda
float _lambda;
Undocumented in source.

Mixed In Members

From mixin opCallNew

opCall
auto opCall(T args)
Undocumented in source. Be warned that the author may not have intended to support it.

Inherited Members

From ProxyLinearPrior

proxy_step
void proxy_step()
Undocumented in source.
dup
ProxyLinearPrior dup()
Undocumented in source.

Examples

// basic L1 regularization: loss = 0.03 * | W |
auto l1 = Linear(5).prior(L1Prior(0.03));

// same, but centered around a non-zero matrix: loss = 0.03 * | W - W_p |
auto l2 = Linear(5).prior(L1Prior(0.03, W_p));

Meta