twodlearn.constrained module

Constrained variables

This module defines a set of constrained variables. These variables are trainable, and can only take values inside a given region. For example, PositiveVariable is only allowed to take positive values.

class twodlearn.constrained.BoundedVariable(min, max, initializer, initial_value=None, trainable=True, collections=None, validate_shape=True, caching_device=None, name='variable', variable_def=None, dtype=None, expected_shape=None, import_scope=None, constraint=None, options=None)[source]

Bases: twodlearn.constrained.TransformedVariable

Creates a variable that can only take values inside a range

inverse(value)[source]
property max[source]
property min[source]
transform(value)[source]
class twodlearn.constrained.ConstrainedVariable(initial_value, min=0.0, max=inf, name=None)[source]

Bases: twodlearn.core.common.TdlModel

initial_value[source]
property initializer[source]
max[source]
min[source]
projection(x)[source]
property shape[source]
property value[source]
variable[source]
class twodlearn.constrained.PositiveVariable(initial_value, trainable=True, collections=None, validate_shape=True, caching_device=None, name=None, variable_def=None, dtype=None, expected_shape=None, import_scope=None, constraint=None, **kargs)[source]

Bases: twodlearn.constrained.TransformedVariable

Creates a variable that can only take positive values.

This fuction uses tf.nn.softplus to ensure positive values.

Tdl autoinitialization with arguments:

tolerance[source]

(InputArgument) tolerance for positive variables.

raw[source]

(SimpleParameter) raw value before making a transformation

value[source]

(OutputValue)

inverse(value)[source]
tolerance[source]

tolerance for positive variables.

transform(value)[source]
class twodlearn.constrained.PositiveVariable2(initial_value, trainable=True, collections=None, validate_shape=True, caching_device=None, name=None, variable_def=None, dtype=None, expected_shape=None, import_scope=None, constraint=None, **kargs)[source]

Bases: twodlearn.constrained.TransformedVariable

Creates a variable that can only take positive values. This function uses pow(x,2) as a reparameterization of the variable

inverse(value)[source]
tolerance[source]

tolerance for positive variables.

transform(value)[source]
class twodlearn.constrained.PositiveVariableExp(initial_value, max=None, trainable=True, collections=None, validate_shape=True, caching_device=None, name=None, tolerance=None)[source]

Bases: twodlearn.constrained.TransformedVariable

Creates a variable that can only take positive values.

This function uses exp() as a reparameterization of the variable

Tdl autoinitialization with arguments:

raw[source]

(ParameterInit) raw value before making a transformation

tolerance[source]

(InputArgument) tolerance for positive variables.

max[source]

(InputArgument)

value[source]

(OutputValue)

inverse(value)[source]
max[source]
raw[source]

raw value before making a transformation

tolerance[source]

tolerance for positive variables.

transform(value)[source]
class twodlearn.constrained.TransformedVariable(initial_value, trainable=True, collections=None, validate_shape=True, caching_device=None, name=None, variable_def=None, dtype=None, expected_shape=None, import_scope=None, constraint=None, **kargs)[source]

Bases: twodlearn.core.common.TdlModel

Variable that uses a transformation to ensure the output is constrained.

Initialization is performed using the inverse method raw = tf.Variable(inverse(initial_value))

The value is defined using the transform value = transform(raw)

Tdl autoinitialization with arguments:

raw[source]

(SimpleParameter) raw value before making a transformation

value[source]

(OutputValue)

classmethod init_wrapper(initializer, trainable, **kargs)[source]

wraps the object to be used as an initializer.

property initializer[source]
inverse(value)[source]
raw[source]

raw value before making a transformation

property shape[source]
transform(value)[source]
value[source]