tfp.layers.default_loc_scale_fn
Stay organized with collections
Save and categorize content based on your preferences.
Makes closure which creates loc
, scale
params from tf.get_variable
.
tfp.layers.default_loc_scale_fn(
is_singular=False,
loc_initializer=tf1.initializers.random_normal(stddev=0.1),
untransformed_scale_initializer=tf1.initializers.random_normal(mean=-3.0, stddev=0.1),
loc_regularizer=None,
untransformed_scale_regularizer=None,
loc_constraint=None,
untransformed_scale_constraint=None
)
This function produces a closure which produces loc
, scale
using
tf.get_variable
. The closure accepts the following arguments:
dtype: Type of parameter's event.
shape: Python list
-like representing the parameter's event shape.
name: Python str
name prepended to any created (or existing)
tf.Variable
s.
trainable: Python bool
indicating all created tf.Variable
s should be
added to the graph collection GraphKeys.TRAINABLE_VARIABLES
.
add_variable_fn: tf.get_variable
-like callable
used to create (or
access existing) tf.Variable
s.
Args |
is_singular
|
Python bool indicating if scale is None . Default: False .
|
loc_initializer
|
Initializer function for the loc parameters.
The default is tf.random_normal_initializer(mean=0., stddev=0.1) .
|
untransformed_scale_initializer
|
Initializer function for the scale
parameters. Default value: tf.random_normal_initializer(mean=-3.,
stddev=0.1) . This implies the softplus transformed result is initialized
near 0 . It allows a Normal distribution with scale parameter set to
this value to approximately act like a point mass.
|
loc_regularizer
|
Regularizer function for the loc parameters.
The default (None ) is to use the tf.get_variable default.
|
untransformed_scale_regularizer
|
Regularizer function for the scale
parameters. The default (None ) is to use the tf.get_variable default.
|
loc_constraint
|
An optional projection function to be applied to the
loc after being updated by an Optimizer . The function must take as input
the unprojected variable and must return the projected variable (which
must have the same shape). Constraints are not safe to use when doing
asynchronous distributed training.
The default (None ) is to use the tf.get_variable default.
|
untransformed_scale_constraint
|
An optional projection function to be
applied to the scale parameters after being updated by an Optimizer
(e.g. used to implement norm constraints or value constraints). The
function must take as input the unprojected variable and must return the
projected variable (which must have the same shape). Constraints are not
safe to use when doing asynchronous distributed training. The default
(None ) is to use the tf.get_variable default.
|
Returns |
default_loc_scale_fn
|
Python callable which instantiates loc , scale
parameters from args: dtype, shape, name, trainable, add_variable_fn .
|
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2023-11-21 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2023-11-21 UTC."],[],[],null,["# tfp.layers.default_loc_scale_fn\n\n\u003cbr /\u003e\n\n|---------------------------------------------------------------------------------------------------------------------------------------|\n| [View source on GitHub](https://github.com/tensorflow/probability/blob/v0.23.0/tensorflow_probability/python/layers/util.py#L42-L120) |\n\nMakes closure which creates `loc`, `scale` params from `tf.get_variable`.\n\n#### View aliases\n\n\n**Main aliases**\n\n[`tfp.layers.util.default_loc_scale_fn`](https://www.tensorflow.org/probability/api_docs/python/tfp/layers/default_loc_scale_fn)\n\n\u003cbr /\u003e\n\n tfp.layers.default_loc_scale_fn(\n is_singular=False,\n loc_initializer=tf1.initializers.random_normal(stddev=0.1),\n untransformed_scale_initializer=tf1.initializers.random_normal(mean=-3.0, stddev=0.1),\n loc_regularizer=None,\n untransformed_scale_regularizer=None,\n loc_constraint=None,\n untransformed_scale_constraint=None\n )\n\nThis function produces a closure which produces `loc`, `scale` using\n`tf.get_variable`. The closure accepts the following arguments:\n\ndtype: Type of parameter's event.\nshape: Python `list`-like representing the parameter's event shape.\nname: Python `str` name prepended to any created (or existing)\n[`tf.Variable`](https://www.tensorflow.org/api_docs/python/tf/Variable)s.\ntrainable: Python `bool` indicating all created [`tf.Variable`](https://www.tensorflow.org/api_docs/python/tf/Variable)s should be\nadded to the graph collection `GraphKeys.TRAINABLE_VARIABLES`.\nadd_variable_fn: `tf.get_variable`-like `callable` used to create (or\naccess existing) [`tf.Variable`](https://www.tensorflow.org/api_docs/python/tf/Variable)s.\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Args ---- ||\n|-----------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `is_singular` | Python `bool` indicating if `scale is None`. Default: `False`. |\n| `loc_initializer` | Initializer function for the `loc` parameters. The default is [`tf.random_normal_initializer(mean=0., stddev=0.1)`](https://www.tensorflow.org/api_docs/python/tf/random_normal_initializer). |\n| `untransformed_scale_initializer` | Initializer function for the `scale` parameters. Default value: `tf.random_normal_initializer(mean=-3., stddev=0.1)`. This implies the softplus transformed result is initialized near `0`. It allows a `Normal` distribution with `scale` parameter set to this value to approximately act like a point mass. |\n| `loc_regularizer` | Regularizer function for the `loc` parameters. The default (`None`) is to use the `tf.get_variable` default. |\n| `untransformed_scale_regularizer` | Regularizer function for the `scale` parameters. The default (`None`) is to use the `tf.get_variable` default. |\n| `loc_constraint` | An optional projection function to be applied to the loc after being updated by an `Optimizer`. The function must take as input the unprojected variable and must return the projected variable (which must have the same shape). Constraints are not safe to use when doing asynchronous distributed training. The default (`None`) is to use the `tf.get_variable` default. |\n| `untransformed_scale_constraint` | An optional projection function to be applied to the `scale` parameters after being updated by an `Optimizer` (e.g. used to implement norm constraints or value constraints). The function must take as input the unprojected variable and must return the projected variable (which must have the same shape). Constraints are not safe to use when doing asynchronous distributed training. The default (`None`) is to use the `tf.get_variable` default. |\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Returns ------- ||\n|------------------------|-----------------------------------------------------------------------------------------------------------------------------|\n| `default_loc_scale_fn` | Python `callable` which instantiates `loc`, `scale` parameters from args: `dtype, shape, name, trainable, add_variable_fn`. |\n\n\u003cbr /\u003e"]]