Layers#
Implement some simple re-parameterization.
Classes#
Identity layer does nothing to the parameters. It is used to be base class for other layers. |
|
NonNegative layer ensures that all parameters are non-negative. |
|
LinearConstraint layer ensures that the parameters satisfy the linear constraint: |
|
SimplexConstraint layer ensures that the parameters satisfy the linear constraint: |
|
BoxConstraint layer ensures that the parameters are in the box: |
|
OffsetSparse layer ensures that the sparse constraint of sparse solvers changes from |
- class skscope.layer.BoxConstraint(dimensionality, lower, upper)[source]#
BoxConstraint layer ensures that the parameters are in the box:
lower <= params <= upper.- Parameters:
dimensionality (int) – Dimensionality of the parameters.
lower (float or array with shape (dimensionality,)) – Lower bound of the box, if
loweris a float, thenlower * ones(dimensionality)is used.lowermust be non-positive.upper (float or array with shape (dimensionality,)) – Upper bound of the box, if
upperis a float, thenupper * ones(dimensionality)is used.uppermust be non-negative.
- class skscope.layer.Identity(dimensionality)[source]#
Identity layer does nothing to the parameters. It is used to be base class for other layers.
- Parameters:
dimensionality (int) – Dimensionality of the parameters.
- class skscope.layer.LinearConstraint(dimensionality, coef=None)[source]#
LinearConstraint layer ensures that the parameters satisfy the linear constraint:
<coef, params> = 1.- Parameters:
dimensionality (int) – Dimensionality of the parameters.
coef (float or array with shape (dimensionality,)) – Coefficients of the linear constraint
<coef, params> = 1. Ifcoefis a float, thencoef * ones(dimensionality)is used.
- class skscope.layer.NonNegative(dimensionality)[source]#
NonNegative layer ensures that all parameters are non-negative.
- Parameters:
dimensionality (int) – Dimensionality of the parameters.
- class skscope.layer.OffsetSparse(dimensionality, offset)[source]#
OffsetSparse layer ensures that the sparse constraint of sparse solvers changes from
||params||_0 = sto||params - offset||_0 = s. In other words, the layer ensures that the parameters corresponding to the non-selected features are equal tooffsetrather than zero.- Parameters:
dimensionality (int) – Dimensionality of the parameters.
offset (float or array with shape (dimensionality,)) – Offset of the sparse constraint.
- class skscope.layer.SimplexConstraint(dimensionality, coef=None)[source]#
SimplexConstraint layer ensures that the parameters satisfy the linear constraint:
<coef, params> = 1and all parameters are non-negative.- Parameters:
dimensionality (int) – Dimensionality of the parameters.
coef (float or array with shape (dimensionality,)) – Coefficients of the linear constraint
<coef, params> = 1. Ifcoefis a float, thencoef * ones(dimensionality)is used.