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.TransformedVariableCreates a variable that can only take values inside a range
- 
class 
twodlearn.constrained.ConstrainedVariable(initial_value, min=0.0, max=inf, name=None)[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.TransformedVariableCreates 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
- 
tolerance[source] tolerance for positive variables.
- 
 
- 
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.TransformedVariableCreates a variable that can only take positive values. This function uses pow(x,2) as a reparameterization of the variable
- 
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.TransformedVariableCreates a variable that can only take positive values.
This function uses
exp()as a reparameterization of the variableTdl autoinitialization with arguments:
- 
raw[source]¶ (
ParameterInit) raw value before making a transformation
- 
tolerance[source]¶ (
InputArgument) tolerance for positive variables.
- 
max[source] 
- 
raw[source] raw value before making a transformation
- 
tolerance[source] tolerance for positive variables.
- 
 
- 
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.TdlModelVariable 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
- 
classmethod 
init_wrapper(initializer, trainable, **kargs)[source]¶ wraps the object to be used as an initializer.
- 
raw[source] raw value before making a transformation
- 
value[source] 
-