Layers#

Implement some simple re-parameterization.

Classes#

Identity

Identity layer does nothing to the parameters. It is used to be base class for other layers.

NonNegative

NonNegative layer ensures that all parameters are non-negative.

LinearConstraint

LinearConstraint layer ensures that the parameters satisfy the linear constraint: <coef, params> = 1.

SimplexConstraint

SimplexConstraint layer ensures that the parameters satisfy the linear constraint: <coef, params> = 1 and all parameters are non-negative.

BoxConstraint

BoxConstraint layer ensures that the parameters are in the box: lower <= params <= upper.

OffsetSparse

OffsetSparse layer ensures that the sparse constraint of sparse solvers changes from ||params||_0 = s to ||params - offset||_0 = s. In other words, the layer ensures that the parameters corresponding to the non-selected features are equal to offset rather than zero.

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 lower is a float, then lower * ones(dimensionality) is used. lower must be non-positive.

  • upper (float or array with shape (dimensionality,)) – Upper bound of the box, if upper is a float, then upper * ones(dimensionality) is used. upper must be non-negative.

transform_params(params)[source]#
tree_flatten()[source]#
classmethod tree_unflatten(aux_data, children)[source]#
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.

random_initilization = False[source]#
transform_group(group)[source]#
transform_params(params)[source]#
transform_preselect(preselect)[source]#
transform_sparsity(sparsity)[source]#
tree_flatten()[source]#
classmethod tree_unflatten(aux_data, children)[source]#
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. If coef is a float, then coef * ones(dimensionality) is used.

random_initilization = True[source]#
transform_params(params)[source]#
tree_flatten()[source]#
classmethod tree_unflatten(aux_data, children)[source]#
class skscope.layer.NonNegative(dimensionality)[source]#

NonNegative layer ensures that all parameters are non-negative.

Parameters:

dimensionality (int) – Dimensionality of the parameters.

transform_params(params)[source]#
class skscope.layer.OffsetSparse(dimensionality, offset)[source]#

OffsetSparse layer ensures that the sparse constraint of sparse solvers changes from ||params||_0 = s to ||params - offset||_0 = s. In other words, the layer ensures that the parameters corresponding to the non-selected features are equal to offset rather than zero.

Parameters:
  • dimensionality (int) – Dimensionality of the parameters.

  • offset (float or array with shape (dimensionality,)) – Offset of the sparse constraint.

transform_params(params)[source]#
tree_flatten()[source]#
classmethod tree_unflatten(aux_data, children)[source]#
class skscope.layer.SimplexConstraint(dimensionality, coef=None)[source]#

SimplexConstraint layer ensures that the parameters satisfy the linear constraint: <coef, params> = 1 and 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. If coef is a float, then coef * ones(dimensionality) is used.

random_initilization = True[source]#
transform_params(params)[source]#
tree_flatten()[source]#
classmethod tree_unflatten(aux_data, children)[source]#