partition
stringclasses
3 values
func_name
stringlengths
1
134
docstring
stringlengths
1
46.9k
path
stringlengths
4
223
original_string
stringlengths
75
104k
code
stringlengths
75
104k
docstring_tokens
listlengths
1
1.97k
repo
stringlengths
7
55
language
stringclasses
1 value
url
stringlengths
87
315
code_tokens
listlengths
19
28.4k
sha
stringlengths
40
40
test
fit
Runs multiple Fisher scoring steps. Args: model_matrix: (Batch of) `float`-like, matrix-shaped `Tensor` where each row represents a sample's features. response: (Batch of) vector-shaped `Tensor` where each element represents a sample's observed response (to the corresponding row of features). Mus...
tensorflow_probability/python/glm/fisher_scoring.py
def fit( model_matrix, response, model, model_coefficients_start=None, predicted_linear_response_start=None, l2_regularizer=None, dispersion=None, offset=None, convergence_criteria_fn=None, learning_rate=None, fast_unsafe_numerics=True, maximum_iterations=None, name=N...
def fit( model_matrix, response, model, model_coefficients_start=None, predicted_linear_response_start=None, l2_regularizer=None, dispersion=None, offset=None, convergence_criteria_fn=None, learning_rate=None, fast_unsafe_numerics=True, maximum_iterations=None, name=N...
[ "Runs", "multiple", "Fisher", "scoring", "steps", "." ]
tensorflow/probability
python
https://github.com/tensorflow/probability/blob/e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5/tensorflow_probability/python/glm/fisher_scoring.py#L36-L256
[ "def", "fit", "(", "model_matrix", ",", "response", ",", "model", ",", "model_coefficients_start", "=", "None", ",", "predicted_linear_response_start", "=", "None", ",", "l2_regularizer", "=", "None", ",", "dispersion", "=", "None", ",", "offset", "=", "None", ...
e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5
test
fit_one_step
Runs one step of Fisher scoring. Args: model_matrix: (Batch of) `float`-like, matrix-shaped `Tensor` where each row represents a sample's features. response: (Batch of) vector-shaped `Tensor` where each element represents a sample's observed response (to the corresponding row of features). Must ...
tensorflow_probability/python/glm/fisher_scoring.py
def fit_one_step( model_matrix, response, model, model_coefficients_start=None, predicted_linear_response_start=None, l2_regularizer=None, dispersion=None, offset=None, learning_rate=None, fast_unsafe_numerics=True, name=None): """Runs one step of Fisher scoring. Args: ...
def fit_one_step( model_matrix, response, model, model_coefficients_start=None, predicted_linear_response_start=None, l2_regularizer=None, dispersion=None, offset=None, learning_rate=None, fast_unsafe_numerics=True, name=None): """Runs one step of Fisher scoring. Args: ...
[ "Runs", "one", "step", "of", "Fisher", "scoring", "." ]
tensorflow/probability
python
https://github.com/tensorflow/probability/blob/e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5/tensorflow_probability/python/glm/fisher_scoring.py#L259-L439
[ "def", "fit_one_step", "(", "model_matrix", ",", "response", ",", "model", ",", "model_coefficients_start", "=", "None", ",", "predicted_linear_response_start", "=", "None", ",", "l2_regularizer", "=", "None", ",", "dispersion", "=", "None", ",", "offset", "=", ...
e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5
test
convergence_criteria_small_relative_norm_weights_change
Returns Python `callable` which indicates fitting procedure has converged. Writing old, new `model_coefficients` as `w0`, `w1`, this function defines convergence as, ```python relative_euclidean_norm = (tf.norm(w0 - w1, ord=2, axis=-1) / (1. + tf.norm(w0, ord=2, axis=-1))) reduc...
tensorflow_probability/python/glm/fisher_scoring.py
def convergence_criteria_small_relative_norm_weights_change( tolerance=1e-5, norm_order=2): """Returns Python `callable` which indicates fitting procedure has converged. Writing old, new `model_coefficients` as `w0`, `w1`, this function defines convergence as, ```python relative_euclidean_norm = (tf...
def convergence_criteria_small_relative_norm_weights_change( tolerance=1e-5, norm_order=2): """Returns Python `callable` which indicates fitting procedure has converged. Writing old, new `model_coefficients` as `w0`, `w1`, this function defines convergence as, ```python relative_euclidean_norm = (tf...
[ "Returns", "Python", "callable", "which", "indicates", "fitting", "procedure", "has", "converged", "." ]
tensorflow/probability
python
https://github.com/tensorflow/probability/blob/e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5/tensorflow_probability/python/glm/fisher_scoring.py#L442-L514
[ "def", "convergence_criteria_small_relative_norm_weights_change", "(", "tolerance", "=", "1e-5", ",", "norm_order", "=", "2", ")", ":", "def", "convergence_criteria_fn", "(", "is_converged_previous", ",", "# pylint: disable=unused-argument", "iter_", ",", "model_coefficients_...
e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5
test
prepare_args
Helper to `fit` which sanitizes input args. Args: model_matrix: (Batch of) `float`-like, matrix-shaped `Tensor` where each row represents a sample's features. response: (Batch of) vector-shaped `Tensor` where each element represents a sample's observed response (to the corresponding row of featur...
tensorflow_probability/python/glm/fisher_scoring.py
def prepare_args(model_matrix, response, model_coefficients, predicted_linear_response, offset, name=None): """Helper to `fit` which sanitizes input args. Args: model_matrix: (Batch of) `float`-like, matrix-shaped `Tensor` whe...
def prepare_args(model_matrix, response, model_coefficients, predicted_linear_response, offset, name=None): """Helper to `fit` which sanitizes input args. Args: model_matrix: (Batch of) `float`-like, matrix-shaped `Tensor` whe...
[ "Helper", "to", "fit", "which", "sanitizes", "input", "args", "." ]
tensorflow/probability
python
https://github.com/tensorflow/probability/blob/e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5/tensorflow_probability/python/glm/fisher_scoring.py#L517-L620
[ "def", "prepare_args", "(", "model_matrix", ",", "response", ",", "model_coefficients", ",", "predicted_linear_response", ",", "offset", ",", "name", "=", "None", ")", ":", "graph_deps", "=", "[", "model_matrix", ",", "response", ",", "model_coefficients", ",", ...
e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5
test
calculate_linear_predictor
Computes `model_matrix @ model_coefficients + offset`.
tensorflow_probability/python/glm/fisher_scoring.py
def calculate_linear_predictor(model_matrix, model_coefficients, offset=None, name=None): """Computes `model_matrix @ model_coefficients + offset`.""" with tf.compat.v1.name_scope(name, 'calculate_linear_predictor', [model_matrix, model_coefficients, off...
def calculate_linear_predictor(model_matrix, model_coefficients, offset=None, name=None): """Computes `model_matrix @ model_coefficients + offset`.""" with tf.compat.v1.name_scope(name, 'calculate_linear_predictor', [model_matrix, model_coefficients, off...
[ "Computes", "model_matrix" ]
tensorflow/probability
python
https://github.com/tensorflow/probability/blob/e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5/tensorflow_probability/python/glm/fisher_scoring.py#L623-L632
[ "def", "calculate_linear_predictor", "(", "model_matrix", ",", "model_coefficients", ",", "offset", "=", "None", ",", "name", "=", "None", ")", ":", "with", "tf", ".", "compat", ".", "v1", ".", "name_scope", "(", "name", ",", "'calculate_linear_predictor'", ",...
e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5
test
num_cols
Returns number of cols in a given `Tensor`.
tensorflow_probability/python/glm/fisher_scoring.py
def num_cols(x): """Returns number of cols in a given `Tensor`.""" if tf.compat.dimension_value(x.shape[-1]) is not None: return tf.compat.dimension_value(x.shape[-1]) return tf.shape(input=x)[-1]
def num_cols(x): """Returns number of cols in a given `Tensor`.""" if tf.compat.dimension_value(x.shape[-1]) is not None: return tf.compat.dimension_value(x.shape[-1]) return tf.shape(input=x)[-1]
[ "Returns", "number", "of", "cols", "in", "a", "given", "Tensor", "." ]
tensorflow/probability
python
https://github.com/tensorflow/probability/blob/e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5/tensorflow_probability/python/glm/fisher_scoring.py#L635-L639
[ "def", "num_cols", "(", "x", ")", ":", "if", "tf", ".", "compat", ".", "dimension_value", "(", "x", ".", "shape", "[", "-", "1", "]", ")", "is", "not", "None", ":", "return", "tf", ".", "compat", ".", "dimension_value", "(", "x", ".", "shape", "[...
e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5
test
_prefer_static
Wraps original_fn, preferring to call static_fn when inputs are static.
tensorflow_probability/python/internal/prefer_static.py
def _prefer_static(original_fn, static_fn): """Wraps original_fn, preferring to call static_fn when inputs are static.""" original_spec = tf_inspect.getfullargspec(original_fn) static_spec = tf_inspect.getfullargspec(static_fn) if original_spec != static_spec: raise ValueError( 'Arg specs do not mat...
def _prefer_static(original_fn, static_fn): """Wraps original_fn, preferring to call static_fn when inputs are static.""" original_spec = tf_inspect.getfullargspec(original_fn) static_spec = tf_inspect.getfullargspec(static_fn) if original_spec != static_spec: raise ValueError( 'Arg specs do not mat...
[ "Wraps", "original_fn", "preferring", "to", "call", "static_fn", "when", "inputs", "are", "static", "." ]
tensorflow/probability
python
https://github.com/tensorflow/probability/blob/e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5/tensorflow_probability/python/internal/prefer_static.py#L41-L56
[ "def", "_prefer_static", "(", "original_fn", ",", "static_fn", ")", ":", "original_spec", "=", "tf_inspect", ".", "getfullargspec", "(", "original_fn", ")", "static_spec", "=", "tf_inspect", ".", "getfullargspec", "(", "static_fn", ")", "if", "original_spec", "!="...
e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5
test
_copy_docstring
Wraps new_fn with the doc of original_fn.
tensorflow_probability/python/internal/prefer_static.py
def _copy_docstring(original_fn, new_fn): """Wraps new_fn with the doc of original_fn.""" original_spec = tf_inspect.getfullargspec(original_fn) new_spec = tf_inspect.getfullargspec(new_fn) if original_spec != new_spec: raise ValueError( 'Arg specs do not match: original={}, new={}, fn={}'.format( ...
def _copy_docstring(original_fn, new_fn): """Wraps new_fn with the doc of original_fn.""" original_spec = tf_inspect.getfullargspec(original_fn) new_spec = tf_inspect.getfullargspec(new_fn) if original_spec != new_spec: raise ValueError( 'Arg specs do not match: original={}, new={}, fn={}'.format( ...
[ "Wraps", "new_fn", "with", "the", "doc", "of", "original_fn", "." ]
tensorflow/probability
python
https://github.com/tensorflow/probability/blob/e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5/tensorflow_probability/python/internal/prefer_static.py#L59-L71
[ "def", "_copy_docstring", "(", "original_fn", ",", "new_fn", ")", ":", "original_spec", "=", "tf_inspect", ".", "getfullargspec", "(", "original_fn", ")", "new_spec", "=", "tf_inspect", ".", "getfullargspec", "(", "new_fn", ")", "if", "original_spec", "!=", "new...
e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5
test
_get_static_predicate
Helper function for statically evaluating predicates in `cond`.
tensorflow_probability/python/internal/prefer_static.py
def _get_static_predicate(pred): """Helper function for statically evaluating predicates in `cond`.""" if pred in {0, 1}: # Accept 1/0 as valid boolean values pred_value = bool(pred) elif isinstance(pred, bool): pred_value = pred elif isinstance(pred, tf.Tensor): pred_value = tf.get_static_value(pr...
def _get_static_predicate(pred): """Helper function for statically evaluating predicates in `cond`.""" if pred in {0, 1}: # Accept 1/0 as valid boolean values pred_value = bool(pred) elif isinstance(pred, bool): pred_value = pred elif isinstance(pred, tf.Tensor): pred_value = tf.get_static_value(pr...
[ "Helper", "function", "for", "statically", "evaluating", "predicates", "in", "cond", "." ]
tensorflow/probability
python
https://github.com/tensorflow/probability/blob/e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5/tensorflow_probability/python/internal/prefer_static.py#L78-L97
[ "def", "_get_static_predicate", "(", "pred", ")", ":", "if", "pred", "in", "{", "0", ",", "1", "}", ":", "# Accept 1/0 as valid boolean values", "pred_value", "=", "bool", "(", "pred", ")", "elif", "isinstance", "(", "pred", ",", "bool", ")", ":", "pred_va...
e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5
test
rank_from_shape
Computes `rank` given a `Tensor`'s `shape`.
tensorflow_probability/python/internal/prefer_static.py
def rank_from_shape(shape_tensor_fn, tensorshape=None): """Computes `rank` given a `Tensor`'s `shape`.""" if tensorshape is None: shape_tensor = (shape_tensor_fn() if callable(shape_tensor_fn) else shape_tensor_fn) if (hasattr(shape_tensor, 'shape') and hasattr(shape_tensor.shap...
def rank_from_shape(shape_tensor_fn, tensorshape=None): """Computes `rank` given a `Tensor`'s `shape`.""" if tensorshape is None: shape_tensor = (shape_tensor_fn() if callable(shape_tensor_fn) else shape_tensor_fn) if (hasattr(shape_tensor, 'shape') and hasattr(shape_tensor.shap...
[ "Computes", "rank", "given", "a", "Tensor", "s", "shape", "." ]
tensorflow/probability
python
https://github.com/tensorflow/probability/blob/e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5/tensorflow_probability/python/internal/prefer_static.py#L100-L117
[ "def", "rank_from_shape", "(", "shape_tensor_fn", ",", "tensorshape", "=", "None", ")", ":", "if", "tensorshape", "is", "None", ":", "shape_tensor", "=", "(", "shape_tensor_fn", "(", ")", "if", "callable", "(", "shape_tensor_fn", ")", "else", "shape_tensor_fn", ...
e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5
test
cond
Return either `true_fn()` if predicate `pred` is true else `false_fn()`. If `pred` is a bool or has a constant value, we return either `true_fn()` or `false_fn()`, otherwise we use `tf.cond` to dynamically route to both. Arguments: pred: A scalar determining whether to return the result of `true_fn` or ...
tensorflow_probability/python/internal/prefer_static.py
def cond(pred, true_fn=None, false_fn=None, name=None): """Return either `true_fn()` if predicate `pred` is true else `false_fn()`. If `pred` is a bool or has a constant value, we return either `true_fn()` or `false_fn()`, otherwise we use `tf.cond` to dynamically route to both. Arguments: pred: A scalar ...
def cond(pred, true_fn=None, false_fn=None, name=None): """Return either `true_fn()` if predicate `pred` is true else `false_fn()`. If `pred` is a bool or has a constant value, we return either `true_fn()` or `false_fn()`, otherwise we use `tf.cond` to dynamically route to both. Arguments: pred: A scalar ...
[ "Return", "either", "true_fn", "()", "if", "predicate", "pred", "is", "true", "else", "false_fn", "()", "." ]
tensorflow/probability
python
https://github.com/tensorflow/probability/blob/e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5/tensorflow_probability/python/internal/prefer_static.py#L120-L151
[ "def", "cond", "(", "pred", ",", "true_fn", "=", "None", ",", "false_fn", "=", "None", ",", "name", "=", "None", ")", ":", "if", "not", "callable", "(", "true_fn", ")", ":", "raise", "TypeError", "(", "'`true_fn` must be callable.'", ")", "if", "not", ...
e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5
test
case
Like tf.case, except attempts to statically evaluate predicates. If any predicate in `pred_fn_pairs` is a bool or has a constant value, the associated callable will be called or omitted depending on its value. Otherwise this functions like tf.case. Args: pred_fn_pairs: Dict or list of pairs of a boolean s...
tensorflow_probability/python/internal/prefer_static.py
def case(pred_fn_pairs, default=None, exclusive=False, name='smart_case'): """Like tf.case, except attempts to statically evaluate predicates. If any predicate in `pred_fn_pairs` is a bool or has a constant value, the associated callable will be called or omitted depending on its value. Otherwise this function...
def case(pred_fn_pairs, default=None, exclusive=False, name='smart_case'): """Like tf.case, except attempts to statically evaluate predicates. If any predicate in `pred_fn_pairs` is a bool or has a constant value, the associated callable will be called or omitted depending on its value. Otherwise this function...
[ "Like", "tf", ".", "case", "except", "attempts", "to", "statically", "evaluate", "predicates", "." ]
tensorflow/probability
python
https://github.com/tensorflow/probability/blob/e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5/tensorflow_probability/python/internal/prefer_static.py#L154-L179
[ "def", "case", "(", "pred_fn_pairs", ",", "default", "=", "None", ",", "exclusive", "=", "False", ",", "name", "=", "'smart_case'", ")", ":", "return", "control_flow_ops", ".", "_case_helper", "(", "# pylint: disable=protected-access", "cond", ",", "pred_fn_pairs"...
e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5
test
ExponentialFamily.log_prob
Computes `D(param=mean(r)).log_prob(response)` for linear response, `r`. Args: response: `float`-like `Tensor` representing observed ("actual") responses. predicted_linear_response: `float`-like `Tensor` corresponding to `tf.matmul(model_matrix, weights)`. name: Python `str` used ...
tensorflow_probability/python/glm/family.py
def log_prob(self, response, predicted_linear_response, name=None): """Computes `D(param=mean(r)).log_prob(response)` for linear response, `r`. Args: response: `float`-like `Tensor` representing observed ("actual") responses. predicted_linear_response: `float`-like `Tensor` corresponding to...
def log_prob(self, response, predicted_linear_response, name=None): """Computes `D(param=mean(r)).log_prob(response)` for linear response, `r`. Args: response: `float`-like `Tensor` representing observed ("actual") responses. predicted_linear_response: `float`-like `Tensor` corresponding to...
[ "Computes", "D", "(", "param", "=", "mean", "(", "r", "))", ".", "log_prob", "(", "response", ")", "for", "linear", "response", "r", "." ]
tensorflow/probability
python
https://github.com/tensorflow/probability/blob/e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5/tensorflow_probability/python/glm/family.py#L137-L161
[ "def", "log_prob", "(", "self", ",", "response", ",", "predicted_linear_response", ",", "name", "=", "None", ")", ":", "with", "self", ".", "_name_scope", "(", "name", ",", "'log_prob'", ",", "[", "response", ",", "predicted_linear_response", "]", ")", ":", ...
e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5
test
ExponentialFamily._name_scope
Helper function to standardize op scope.
tensorflow_probability/python/glm/family.py
def _name_scope(self, name=None, default_name=None, values=None): """Helper function to standardize op scope.""" with tf.compat.v1.name_scope(self.name): with tf.compat.v1.name_scope( name, default_name, values=values or []) as scope: yield scope
def _name_scope(self, name=None, default_name=None, values=None): """Helper function to standardize op scope.""" with tf.compat.v1.name_scope(self.name): with tf.compat.v1.name_scope( name, default_name, values=values or []) as scope: yield scope
[ "Helper", "function", "to", "standardize", "op", "scope", "." ]
tensorflow/probability
python
https://github.com/tensorflow/probability/blob/e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5/tensorflow_probability/python/glm/family.py#L174-L179
[ "def", "_name_scope", "(", "self", ",", "name", "=", "None", ",", "default_name", "=", "None", ",", "values", "=", "None", ")", ":", "with", "tf", ".", "compat", ".", "v1", ".", "name_scope", "(", "self", ".", "name", ")", ":", "with", "tf", ".", ...
e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5
test
mixture_stddev
Computes the standard deviation of a mixture distribution. This function works regardless of the component distribution, so long as each component's mean and standard deviation can be provided. Args: mixture_weight_vector: A 2D tensor with shape [batch_size, num_components] mean_vector: A 2D tensor of m...
tensorflow_probability/python/internal/distribution_util.py
def mixture_stddev(mixture_weight_vector, mean_vector, stddev_vector): """Computes the standard deviation of a mixture distribution. This function works regardless of the component distribution, so long as each component's mean and standard deviation can be provided. Args: mixture_weight_vector: A 2D tens...
def mixture_stddev(mixture_weight_vector, mean_vector, stddev_vector): """Computes the standard deviation of a mixture distribution. This function works regardless of the component distribution, so long as each component's mean and standard deviation can be provided. Args: mixture_weight_vector: A 2D tens...
[ "Computes", "the", "standard", "deviation", "of", "a", "mixture", "distribution", "." ]
tensorflow/probability
python
https://github.com/tensorflow/probability/blob/e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5/tensorflow_probability/python/internal/distribution_util.py#L39-L82
[ "def", "mixture_stddev", "(", "mixture_weight_vector", ",", "mean_vector", ",", "stddev_vector", ")", ":", "tensorshape_util", ".", "assert_has_rank", "(", "mixture_weight_vector", ".", "shape", ",", "2", ")", "if", "not", "tensorshape_util", ".", "is_compatible_with"...
e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5
test
make_tril_scale
Creates a LinearOperator representing a lower triangular matrix. Args: loc: Floating-point `Tensor`. This is used for inferring shape in the case where only `scale_identity_multiplier` is set. scale_tril: Floating-point `Tensor` representing the diagonal matrix. `scale_diag` has shape [N1, N2, .....
tensorflow_probability/python/internal/distribution_util.py
def make_tril_scale(loc=None, scale_tril=None, scale_diag=None, scale_identity_multiplier=None, shape_hint=None, validate_args=False, assert_positive=False, name=None): """Create...
def make_tril_scale(loc=None, scale_tril=None, scale_diag=None, scale_identity_multiplier=None, shape_hint=None, validate_args=False, assert_positive=False, name=None): """Create...
[ "Creates", "a", "LinearOperator", "representing", "a", "lower", "triangular", "matrix", "." ]
tensorflow/probability
python
https://github.com/tensorflow/probability/blob/e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5/tensorflow_probability/python/internal/distribution_util.py#L85-L177
[ "def", "make_tril_scale", "(", "loc", "=", "None", ",", "scale_tril", "=", "None", ",", "scale_diag", "=", "None", ",", "scale_identity_multiplier", "=", "None", ",", "shape_hint", "=", "None", ",", "validate_args", "=", "False", ",", "assert_positive", "=", ...
e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5
test
make_diag_scale
Creates a LinearOperator representing a diagonal matrix. Args: loc: Floating-point `Tensor`. This is used for inferring shape in the case where only `scale_identity_multiplier` is set. scale_diag: Floating-point `Tensor` representing the diagonal matrix. `scale_diag` has shape [N1, N2, ... k], w...
tensorflow_probability/python/internal/distribution_util.py
def make_diag_scale(loc=None, scale_diag=None, scale_identity_multiplier=None, shape_hint=None, validate_args=False, assert_positive=False, name=None, dtype=None): """Creates a L...
def make_diag_scale(loc=None, scale_diag=None, scale_identity_multiplier=None, shape_hint=None, validate_args=False, assert_positive=False, name=None, dtype=None): """Creates a L...
[ "Creates", "a", "LinearOperator", "representing", "a", "diagonal", "matrix", "." ]
tensorflow/probability
python
https://github.com/tensorflow/probability/blob/e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5/tensorflow_probability/python/internal/distribution_util.py#L180-L278
[ "def", "make_diag_scale", "(", "loc", "=", "None", ",", "scale_diag", "=", "None", ",", "scale_identity_multiplier", "=", "None", ",", "shape_hint", "=", "None", ",", "validate_args", "=", "False", ",", "assert_positive", "=", "False", ",", "name", "=", "Non...
e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5
test
shapes_from_loc_and_scale
Infer distribution batch and event shapes from a location and scale. Location and scale family distributions determine their batch/event shape by broadcasting the `loc` and `scale` args. This helper does that broadcast, statically if possible. Batch shape broadcasts as per the normal rules. We allow the `l...
tensorflow_probability/python/internal/distribution_util.py
def shapes_from_loc_and_scale(loc, scale, name="shapes_from_loc_and_scale"): """Infer distribution batch and event shapes from a location and scale. Location and scale family distributions determine their batch/event shape by broadcasting the `loc` and `scale` args. This helper does that broadcast, statically...
def shapes_from_loc_and_scale(loc, scale, name="shapes_from_loc_and_scale"): """Infer distribution batch and event shapes from a location and scale. Location and scale family distributions determine their batch/event shape by broadcasting the `loc` and `scale` args. This helper does that broadcast, statically...
[ "Infer", "distribution", "batch", "and", "event", "shapes", "from", "a", "location", "and", "scale", "." ]
tensorflow/probability
python
https://github.com/tensorflow/probability/blob/e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5/tensorflow_probability/python/internal/distribution_util.py#L281-L351
[ "def", "shapes_from_loc_and_scale", "(", "loc", ",", "scale", ",", "name", "=", "\"shapes_from_loc_and_scale\"", ")", ":", "if", "loc", "is", "not", "None", "and", "tensorshape_util", ".", "rank", "(", "loc", ".", "shape", ")", "==", "0", ":", "loc", "=", ...
e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5
test
get_broadcast_shape
Get broadcast shape as a Python list of integers (preferred) or `Tensor`. Args: *tensors: One or more `Tensor` objects (already converted!). Returns: broadcast shape: Python list (if shapes determined statically), otherwise an `int32` `Tensor`.
tensorflow_probability/python/internal/distribution_util.py
def get_broadcast_shape(*tensors): """Get broadcast shape as a Python list of integers (preferred) or `Tensor`. Args: *tensors: One or more `Tensor` objects (already converted!). Returns: broadcast shape: Python list (if shapes determined statically), otherwise an `int32` `Tensor`. """ # Try...
def get_broadcast_shape(*tensors): """Get broadcast shape as a Python list of integers (preferred) or `Tensor`. Args: *tensors: One or more `Tensor` objects (already converted!). Returns: broadcast shape: Python list (if shapes determined statically), otherwise an `int32` `Tensor`. """ # Try...
[ "Get", "broadcast", "shape", "as", "a", "Python", "list", "of", "integers", "(", "preferred", ")", "or", "Tensor", "." ]
tensorflow/probability
python
https://github.com/tensorflow/probability/blob/e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5/tensorflow_probability/python/internal/distribution_util.py#L354-L375
[ "def", "get_broadcast_shape", "(", "*", "tensors", ")", ":", "# Try static.", "s_shape", "=", "tensors", "[", "0", "]", ".", "shape", "for", "t", "in", "tensors", "[", "1", ":", "]", ":", "s_shape", "=", "tf", ".", "broadcast_static_shape", "(", "s_shape...
e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5
test
is_diagonal_scale
Returns `True` if `scale` is a `LinearOperator` that is known to be diag. Args: scale: `LinearOperator` instance. Returns: Python `bool`. Raises: TypeError: If `scale` is not a `LinearOperator`.
tensorflow_probability/python/internal/distribution_util.py
def is_diagonal_scale(scale): """Returns `True` if `scale` is a `LinearOperator` that is known to be diag. Args: scale: `LinearOperator` instance. Returns: Python `bool`. Raises: TypeError: If `scale` is not a `LinearOperator`. """ if not isinstance(scale, tf.linalg.LinearOperator): rai...
def is_diagonal_scale(scale): """Returns `True` if `scale` is a `LinearOperator` that is known to be diag. Args: scale: `LinearOperator` instance. Returns: Python `bool`. Raises: TypeError: If `scale` is not a `LinearOperator`. """ if not isinstance(scale, tf.linalg.LinearOperator): rai...
[ "Returns", "True", "if", "scale", "is", "a", "LinearOperator", "that", "is", "known", "to", "be", "diag", "." ]
tensorflow/probability
python
https://github.com/tensorflow/probability/blob/e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5/tensorflow_probability/python/internal/distribution_util.py#L378-L395
[ "def", "is_diagonal_scale", "(", "scale", ")", ":", "if", "not", "isinstance", "(", "scale", ",", "tf", ".", "linalg", ".", "LinearOperator", ")", ":", "raise", "TypeError", "(", "\"Expected argument 'scale' to be instance of LinearOperator\"", "\". Found: %s\"", "%",...
e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5
test
maybe_check_scalar_distribution
Helper which checks validity of a scalar `distribution` init arg. Valid here means: * `distribution` has scalar batch and event shapes. * `distribution` is `FULLY_REPARAMETERIZED` * `distribution` has expected dtype. Args: distribution: `Distribution`-like object. expected_base_dtype: `TensorFlow...
tensorflow_probability/python/internal/distribution_util.py
def maybe_check_scalar_distribution(distribution, expected_base_dtype, validate_args): """Helper which checks validity of a scalar `distribution` init arg. Valid here means: * `distribution` has scalar batch and event shapes. * `distribution` is `FULLY_REPARAMETERIZED` * ...
def maybe_check_scalar_distribution(distribution, expected_base_dtype, validate_args): """Helper which checks validity of a scalar `distribution` init arg. Valid here means: * `distribution` has scalar batch and event shapes. * `distribution` is `FULLY_REPARAMETERIZED` * ...
[ "Helper", "which", "checks", "validity", "of", "a", "scalar", "distribution", "init", "arg", "." ]
tensorflow/probability
python
https://github.com/tensorflow/probability/blob/e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5/tensorflow_probability/python/internal/distribution_util.py#L398-L462
[ "def", "maybe_check_scalar_distribution", "(", "distribution", ",", "expected_base_dtype", ",", "validate_args", ")", ":", "if", "distribution", ".", "dtype", "!=", "expected_base_dtype", ":", "raise", "TypeError", "(", "\"dtype mismatch; \"", "\"distribution.dtype=\\\"{}\\...
e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5
test
pad_mixture_dimensions
Pad dimensions of event tensors for mixture distributions. See `Mixture._sample_n` and `MixtureSameFamily._sample_n` for usage examples. Args: x: event tensor to pad. mixture_distribution: Base distribution of the mixture. categorical_distribution: `Categorical` distribution that mixes the base ...
tensorflow_probability/python/internal/distribution_util.py
def pad_mixture_dimensions(x, mixture_distribution, categorical_distribution, event_ndims): """Pad dimensions of event tensors for mixture distributions. See `Mixture._sample_n` and `MixtureSameFamily._sample_n` for usage examples. Args: x: event tensor to pad. mixture_distrib...
def pad_mixture_dimensions(x, mixture_distribution, categorical_distribution, event_ndims): """Pad dimensions of event tensors for mixture distributions. See `Mixture._sample_n` and `MixtureSameFamily._sample_n` for usage examples. Args: x: event tensor to pad. mixture_distrib...
[ "Pad", "dimensions", "of", "event", "tensors", "for", "mixture", "distributions", "." ]
tensorflow/probability
python
https://github.com/tensorflow/probability/blob/e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5/tensorflow_probability/python/internal/distribution_util.py#L465-L503
[ "def", "pad_mixture_dimensions", "(", "x", ",", "mixture_distribution", ",", "categorical_distribution", ",", "event_ndims", ")", ":", "with", "tf", ".", "name_scope", "(", "\"pad_mix_dims\"", ")", ":", "def", "_get_ndims", "(", "d", ")", ":", "if", "tensorshape...
e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5
test
pick_scalar_condition
Convenience function that chooses one of two values based on the predicate. This utility is equivalent to a version of `tf.where` that accepts only a scalar predicate and computes its result statically when possible. It may also be used in place of `tf.cond` when both branches yield a `Tensor` of the same shap...
tensorflow_probability/python/internal/distribution_util.py
def pick_scalar_condition(pred, true_value, false_value, name=None): """Convenience function that chooses one of two values based on the predicate. This utility is equivalent to a version of `tf.where` that accepts only a scalar predicate and computes its result statically when possible. It may also be used in...
def pick_scalar_condition(pred, true_value, false_value, name=None): """Convenience function that chooses one of two values based on the predicate. This utility is equivalent to a version of `tf.where` that accepts only a scalar predicate and computes its result statically when possible. It may also be used in...
[ "Convenience", "function", "that", "chooses", "one", "of", "two", "values", "based", "on", "the", "predicate", "." ]
tensorflow/probability
python
https://github.com/tensorflow/probability/blob/e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5/tensorflow_probability/python/internal/distribution_util.py#L506-L542
[ "def", "pick_scalar_condition", "(", "pred", ",", "true_value", ",", "false_value", ",", "name", "=", "None", ")", ":", "with", "tf", ".", "name_scope", "(", "name", "or", "\"pick_scalar_condition\"", ")", ":", "pred", "=", "tf", ".", "convert_to_tensor", "(...
e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5
test
make_non_negative_axis
Make (possibly negatively indexed) `axis` argument non-negative.
tensorflow_probability/python/internal/distribution_util.py
def make_non_negative_axis(axis, rank): """Make (possibly negatively indexed) `axis` argument non-negative.""" axis = tf.convert_to_tensor(value=axis, name="axis") rank = tf.convert_to_tensor(value=rank, name="rank") axis_ = tf.get_static_value(axis) rank_ = tf.get_static_value(rank) # Static case. if ax...
def make_non_negative_axis(axis, rank): """Make (possibly negatively indexed) `axis` argument non-negative.""" axis = tf.convert_to_tensor(value=axis, name="axis") rank = tf.convert_to_tensor(value=rank, name="rank") axis_ = tf.get_static_value(axis) rank_ = tf.get_static_value(rank) # Static case. if ax...
[ "Make", "(", "possibly", "negatively", "indexed", ")", "axis", "argument", "non", "-", "negative", "." ]
tensorflow/probability
python
https://github.com/tensorflow/probability/blob/e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5/tensorflow_probability/python/internal/distribution_util.py#L545-L569
[ "def", "make_non_negative_axis", "(", "axis", ",", "rank", ")", ":", "axis", "=", "tf", ".", "convert_to_tensor", "(", "value", "=", "axis", ",", "name", "=", "\"axis\"", ")", "rank", "=", "tf", ".", "convert_to_tensor", "(", "value", "=", "rank", ",", ...
e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5
test
move_dimension
Move a single tensor dimension within its shape. This is a special case of `tf.transpose()`, which applies arbitrary permutations to tensor dimensions. Args: x: Tensor of rank `ndims`. source_idx: Integer index into `x.shape` (negative indexing is supported). dest_idx: Integer index into `x.shape` (...
tensorflow_probability/python/internal/distribution_util.py
def move_dimension(x, source_idx, dest_idx): """Move a single tensor dimension within its shape. This is a special case of `tf.transpose()`, which applies arbitrary permutations to tensor dimensions. Args: x: Tensor of rank `ndims`. source_idx: Integer index into `x.shape` (negative indexing is suppor...
def move_dimension(x, source_idx, dest_idx): """Move a single tensor dimension within its shape. This is a special case of `tf.transpose()`, which applies arbitrary permutations to tensor dimensions. Args: x: Tensor of rank `ndims`. source_idx: Integer index into `x.shape` (negative indexing is suppor...
[ "Move", "a", "single", "tensor", "dimension", "within", "its", "shape", "." ]
tensorflow/probability
python
https://github.com/tensorflow/probability/blob/e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5/tensorflow_probability/python/internal/distribution_util.py#L572-L639
[ "def", "move_dimension", "(", "x", ",", "source_idx", ",", "dest_idx", ")", ":", "ndims", "=", "prefer_static_rank", "(", "x", ")", "dtype", "=", "dtype_util", ".", "common_dtype", "(", "[", "source_idx", ",", "dest_idx", "]", ",", "preferred_dtype", "=", ...
e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5
test
assert_integer_form
Assert that x has integer components (or floats equal to integers). Args: x: Floating-point `Tensor` data: The tensors to print out if the condition is `False`. Defaults to error message and first few entries of `x` and `y`. summarize: Print this many entries of each tensor. message: A string t...
tensorflow_probability/python/internal/distribution_util.py
def assert_integer_form(x, data=None, summarize=None, message=None, int_dtype=None, name="assert_integer_form"): """Assert that x has integer components (or floats equal to integers). Args: x...
def assert_integer_form(x, data=None, summarize=None, message=None, int_dtype=None, name="assert_integer_form"): """Assert that x has integer components (or floats equal to integers). Args: x...
[ "Assert", "that", "x", "has", "integer", "components", "(", "or", "floats", "equal", "to", "integers", ")", "." ]
tensorflow/probability
python
https://github.com/tensorflow/probability/blob/e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5/tensorflow_probability/python/internal/distribution_util.py#L642-L683
[ "def", "assert_integer_form", "(", "x", ",", "data", "=", "None", ",", "summarize", "=", "None", ",", "message", "=", "None", ",", "int_dtype", "=", "None", ",", "name", "=", "\"assert_integer_form\"", ")", ":", "with", "tf", ".", "name_scope", "(", "nam...
e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5
test
embed_check_nonnegative_integer_form
Assert x is a non-negative tensor, and optionally of integers.
tensorflow_probability/python/internal/distribution_util.py
def embed_check_nonnegative_integer_form( x, name="embed_check_nonnegative_integer_form"): """Assert x is a non-negative tensor, and optionally of integers.""" with tf.name_scope(name): x = tf.convert_to_tensor(value=x, name="x") assertions = [ assert_util.assert_non_negative( x, mes...
def embed_check_nonnegative_integer_form( x, name="embed_check_nonnegative_integer_form"): """Assert x is a non-negative tensor, and optionally of integers.""" with tf.name_scope(name): x = tf.convert_to_tensor(value=x, name="x") assertions = [ assert_util.assert_non_negative( x, mes...
[ "Assert", "x", "is", "a", "non", "-", "negative", "tensor", "and", "optionally", "of", "integers", "." ]
tensorflow/probability
python
https://github.com/tensorflow/probability/blob/e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5/tensorflow_probability/python/internal/distribution_util.py#L692-L707
[ "def", "embed_check_nonnegative_integer_form", "(", "x", ",", "name", "=", "\"embed_check_nonnegative_integer_form\"", ")", ":", "with", "tf", ".", "name_scope", "(", "name", ")", ":", "x", "=", "tf", ".", "convert_to_tensor", "(", "value", "=", "x", ",", "nam...
e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5
test
same_dynamic_shape
Returns whether a and b have the same dynamic shape. Args: a: `Tensor` b: `Tensor` Returns: `bool` `Tensor` representing if both tensors have the same shape.
tensorflow_probability/python/internal/distribution_util.py
def same_dynamic_shape(a, b): """Returns whether a and b have the same dynamic shape. Args: a: `Tensor` b: `Tensor` Returns: `bool` `Tensor` representing if both tensors have the same shape. """ a = tf.convert_to_tensor(value=a, name="a") b = tf.convert_to_tensor(value=b, name="b") # Here w...
def same_dynamic_shape(a, b): """Returns whether a and b have the same dynamic shape. Args: a: `Tensor` b: `Tensor` Returns: `bool` `Tensor` representing if both tensors have the same shape. """ a = tf.convert_to_tensor(value=a, name="a") b = tf.convert_to_tensor(value=b, name="b") # Here w...
[ "Returns", "whether", "a", "and", "b", "have", "the", "same", "dynamic", "shape", "." ]
tensorflow/probability
python
https://github.com/tensorflow/probability/blob/e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5/tensorflow_probability/python/internal/distribution_util.py#L710-L737
[ "def", "same_dynamic_shape", "(", "a", ",", "b", ")", ":", "a", "=", "tf", ".", "convert_to_tensor", "(", "value", "=", "a", ",", "name", "=", "\"a\"", ")", "b", "=", "tf", ".", "convert_to_tensor", "(", "value", "=", "b", ",", "name", "=", "\"b\""...
e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5
test
maybe_get_static_value
Helper which tries to return a static value. Given `x`, extract it's value statically, optionally casting to a specific dtype. If this is not possible, None is returned. Args: x: `Tensor` for which to extract a value statically. dtype: Optional dtype to cast to. Returns: Statically inferred value...
tensorflow_probability/python/internal/distribution_util.py
def maybe_get_static_value(x, dtype=None): """Helper which tries to return a static value. Given `x`, extract it's value statically, optionally casting to a specific dtype. If this is not possible, None is returned. Args: x: `Tensor` for which to extract a value statically. dtype: Optional dtype to ca...
def maybe_get_static_value(x, dtype=None): """Helper which tries to return a static value. Given `x`, extract it's value statically, optionally casting to a specific dtype. If this is not possible, None is returned. Args: x: `Tensor` for which to extract a value statically. dtype: Optional dtype to ca...
[ "Helper", "which", "tries", "to", "return", "a", "static", "value", "." ]
tensorflow/probability
python
https://github.com/tensorflow/probability/blob/e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5/tensorflow_probability/python/internal/distribution_util.py#L740-L762
[ "def", "maybe_get_static_value", "(", "x", ",", "dtype", "=", "None", ")", ":", "if", "x", "is", "None", ":", "return", "x", "try", ":", "# This returns an np.ndarray.", "x_", "=", "tf", ".", "get_static_value", "(", "x", ")", "except", "TypeError", ":", ...
e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5
test
get_logits_and_probs
Converts logit to probabilities (or vice-versa), and returns both. Args: logits: Floating-point `Tensor` representing log-odds. probs: Floating-point `Tensor` representing probabilities. multidimensional: Python `bool`, default `False`. If `True`, represents whether the last dimension of `logits` o...
tensorflow_probability/python/internal/distribution_util.py
def get_logits_and_probs(logits=None, probs=None, multidimensional=False, validate_args=False, name="get_logits_and_probs", dtype=None): """Converts logit to probabilities (or vice-versa), and ...
def get_logits_and_probs(logits=None, probs=None, multidimensional=False, validate_args=False, name="get_logits_and_probs", dtype=None): """Converts logit to probabilities (or vice-versa), and ...
[ "Converts", "logit", "to", "probabilities", "(", "or", "vice", "-", "versa", ")", "and", "returns", "both", "." ]
tensorflow/probability
python
https://github.com/tensorflow/probability/blob/e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5/tensorflow_probability/python/internal/distribution_util.py#L765-L845
[ "def", "get_logits_and_probs", "(", "logits", "=", "None", ",", "probs", "=", "None", ",", "multidimensional", "=", "False", ",", "validate_args", "=", "False", ",", "name", "=", "\"get_logits_and_probs\"", ",", "dtype", "=", "None", ")", ":", "if", "dtype",...
e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5
test
_is_known_unsigned_by_dtype
Helper returning True if dtype is known to be unsigned.
tensorflow_probability/python/internal/distribution_util.py
def _is_known_unsigned_by_dtype(dt): """Helper returning True if dtype is known to be unsigned.""" return { tf.bool: True, tf.uint8: True, tf.uint16: True, }.get(dt.base_dtype, False)
def _is_known_unsigned_by_dtype(dt): """Helper returning True if dtype is known to be unsigned.""" return { tf.bool: True, tf.uint8: True, tf.uint16: True, }.get(dt.base_dtype, False)
[ "Helper", "returning", "True", "if", "dtype", "is", "known", "to", "be", "unsigned", "." ]
tensorflow/probability
python
https://github.com/tensorflow/probability/blob/e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5/tensorflow_probability/python/internal/distribution_util.py#L848-L854
[ "def", "_is_known_unsigned_by_dtype", "(", "dt", ")", ":", "return", "{", "tf", ".", "bool", ":", "True", ",", "tf", ".", "uint8", ":", "True", ",", "tf", ".", "uint16", ":", "True", ",", "}", ".", "get", "(", "dt", ".", "base_dtype", ",", "False",...
e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5
test
_is_known_signed_by_dtype
Helper returning True if dtype is known to be signed.
tensorflow_probability/python/internal/distribution_util.py
def _is_known_signed_by_dtype(dt): """Helper returning True if dtype is known to be signed.""" return { tf.float16: True, tf.float32: True, tf.float64: True, tf.int8: True, tf.int16: True, tf.int32: True, tf.int64: True, }.get(dt.base_dtype, False)
def _is_known_signed_by_dtype(dt): """Helper returning True if dtype is known to be signed.""" return { tf.float16: True, tf.float32: True, tf.float64: True, tf.int8: True, tf.int16: True, tf.int32: True, tf.int64: True, }.get(dt.base_dtype, False)
[ "Helper", "returning", "True", "if", "dtype", "is", "known", "to", "be", "signed", "." ]
tensorflow/probability
python
https://github.com/tensorflow/probability/blob/e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5/tensorflow_probability/python/internal/distribution_util.py#L857-L867
[ "def", "_is_known_signed_by_dtype", "(", "dt", ")", ":", "return", "{", "tf", ".", "float16", ":", "True", ",", "tf", ".", "float32", ":", "True", ",", "tf", ".", "float64", ":", "True", ",", "tf", ".", "int8", ":", "True", ",", "tf", ".", "int16",...
e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5
test
_largest_integer_by_dtype
Helper returning the largest integer exactly representable by dtype.
tensorflow_probability/python/internal/distribution_util.py
def _largest_integer_by_dtype(dt): """Helper returning the largest integer exactly representable by dtype.""" if not _is_known_dtype(dt): raise TypeError("Unrecognized dtype: {}".format(dt.name)) if dt.is_floating: return int(2**(np.finfo(dt.as_numpy_dtype).nmant + 1)) if dt.is_integer: return np.ii...
def _largest_integer_by_dtype(dt): """Helper returning the largest integer exactly representable by dtype.""" if not _is_known_dtype(dt): raise TypeError("Unrecognized dtype: {}".format(dt.name)) if dt.is_floating: return int(2**(np.finfo(dt.as_numpy_dtype).nmant + 1)) if dt.is_integer: return np.ii...
[ "Helper", "returning", "the", "largest", "integer", "exactly", "representable", "by", "dtype", "." ]
tensorflow/probability
python
https://github.com/tensorflow/probability/blob/e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5/tensorflow_probability/python/internal/distribution_util.py#L875-L886
[ "def", "_largest_integer_by_dtype", "(", "dt", ")", ":", "if", "not", "_is_known_dtype", "(", "dt", ")", ":", "raise", "TypeError", "(", "\"Unrecognized dtype: {}\"", ".", "format", "(", "dt", ".", "name", ")", ")", "if", "dt", ".", "is_floating", ":", "re...
e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5
test
_smallest_integer_by_dtype
Helper returning the smallest integer exactly representable by dtype.
tensorflow_probability/python/internal/distribution_util.py
def _smallest_integer_by_dtype(dt): """Helper returning the smallest integer exactly representable by dtype.""" if not _is_known_dtype(dt): raise TypeError("Unrecognized dtype: {}".format(dt.name)) if _is_known_unsigned_by_dtype(dt): return 0 return -1 * _largest_integer_by_dtype(dt)
def _smallest_integer_by_dtype(dt): """Helper returning the smallest integer exactly representable by dtype.""" if not _is_known_dtype(dt): raise TypeError("Unrecognized dtype: {}".format(dt.name)) if _is_known_unsigned_by_dtype(dt): return 0 return -1 * _largest_integer_by_dtype(dt)
[ "Helper", "returning", "the", "smallest", "integer", "exactly", "representable", "by", "dtype", "." ]
tensorflow/probability
python
https://github.com/tensorflow/probability/blob/e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5/tensorflow_probability/python/internal/distribution_util.py#L889-L895
[ "def", "_smallest_integer_by_dtype", "(", "dt", ")", ":", "if", "not", "_is_known_dtype", "(", "dt", ")", ":", "raise", "TypeError", "(", "\"Unrecognized dtype: {}\"", ".", "format", "(", "dt", ".", "name", ")", ")", "if", "_is_known_unsigned_by_dtype", "(", "...
e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5
test
_is_integer_like_by_dtype
Helper returning True if dtype.is_integer or is `bool`.
tensorflow_probability/python/internal/distribution_util.py
def _is_integer_like_by_dtype(dt): """Helper returning True if dtype.is_integer or is `bool`.""" if not _is_known_dtype(dt): raise TypeError("Unrecognized dtype: {}".format(dt.name)) return dt.is_integer or dt.base_dtype == tf.bool
def _is_integer_like_by_dtype(dt): """Helper returning True if dtype.is_integer or is `bool`.""" if not _is_known_dtype(dt): raise TypeError("Unrecognized dtype: {}".format(dt.name)) return dt.is_integer or dt.base_dtype == tf.bool
[ "Helper", "returning", "True", "if", "dtype", ".", "is_integer", "or", "is", "bool", "." ]
tensorflow/probability
python
https://github.com/tensorflow/probability/blob/e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5/tensorflow_probability/python/internal/distribution_util.py#L898-L902
[ "def", "_is_integer_like_by_dtype", "(", "dt", ")", ":", "if", "not", "_is_known_dtype", "(", "dt", ")", ":", "raise", "TypeError", "(", "\"Unrecognized dtype: {}\"", ".", "format", "(", "dt", ".", "name", ")", ")", "return", "dt", ".", "is_integer", "or", ...
e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5
test
embed_check_categorical_event_shape
Embeds checks that categorical distributions don't have too many classes. A categorical-type distribution is one which, e.g., returns the class label rather than a one-hot encoding. E.g., `Categorical(probs)`. Since distributions output samples in the same dtype as the parameters, we must ensure that casting...
tensorflow_probability/python/internal/distribution_util.py
def embed_check_categorical_event_shape( categorical_param, name="embed_check_categorical_event_shape"): """Embeds checks that categorical distributions don't have too many classes. A categorical-type distribution is one which, e.g., returns the class label rather than a one-hot encoding. E.g., `Categorical...
def embed_check_categorical_event_shape( categorical_param, name="embed_check_categorical_event_shape"): """Embeds checks that categorical distributions don't have too many classes. A categorical-type distribution is one which, e.g., returns the class label rather than a one-hot encoding. E.g., `Categorical...
[ "Embeds", "checks", "that", "categorical", "distributions", "don", "t", "have", "too", "many", "classes", "." ]
tensorflow/probability
python
https://github.com/tensorflow/probability/blob/e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5/tensorflow_probability/python/internal/distribution_util.py#L905-L999
[ "def", "embed_check_categorical_event_shape", "(", "categorical_param", ",", "name", "=", "\"embed_check_categorical_event_shape\"", ")", ":", "with", "tf", ".", "name_scope", "(", "name", ")", ":", "x", "=", "tf", ".", "convert_to_tensor", "(", "value", "=", "cat...
e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5
test
embed_check_integer_casting_closed
Ensures integers remain unaffected despite casting to/from int/float types. Example integer-types: `uint8`, `int32`, `bool`. Example floating-types: `float32`, `float64`. The largest possible integer representable by an IEEE754 floating-point is `2**(1 + mantissa_bits)` yet the largest possible integer as an ...
tensorflow_probability/python/internal/distribution_util.py
def embed_check_integer_casting_closed(x, target_dtype, assert_nonnegative=True, assert_positive=False, name="embed_check_casting_closed"): """Ensures integers re...
def embed_check_integer_casting_closed(x, target_dtype, assert_nonnegative=True, assert_positive=False, name="embed_check_casting_closed"): """Ensures integers re...
[ "Ensures", "integers", "remain", "unaffected", "despite", "casting", "to", "/", "from", "int", "/", "float", "types", "." ]
tensorflow/probability
python
https://github.com/tensorflow/probability/blob/e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5/tensorflow_probability/python/internal/distribution_util.py#L1002-L1098
[ "def", "embed_check_integer_casting_closed", "(", "x", ",", "target_dtype", ",", "assert_nonnegative", "=", "True", ",", "assert_positive", "=", "False", ",", "name", "=", "\"embed_check_casting_closed\"", ")", ":", "with", "tf", ".", "name_scope", "(", "name", ")...
e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5
test
log_combinations
Multinomial coefficient. Given `n` and `counts`, where `counts` has last dimension `k`, we compute the multinomial coefficient as: ```n! / sum_i n_i!``` where `i` runs over all `k` classes. Args: n: Floating-point `Tensor` broadcastable with `counts`. This represents `n` outcomes. counts: Fl...
tensorflow_probability/python/internal/distribution_util.py
def log_combinations(n, counts, name="log_combinations"): """Multinomial coefficient. Given `n` and `counts`, where `counts` has last dimension `k`, we compute the multinomial coefficient as: ```n! / sum_i n_i!``` where `i` runs over all `k` classes. Args: n: Floating-point `Tensor` broadcastable wi...
def log_combinations(n, counts, name="log_combinations"): """Multinomial coefficient. Given `n` and `counts`, where `counts` has last dimension `k`, we compute the multinomial coefficient as: ```n! / sum_i n_i!``` where `i` runs over all `k` classes. Args: n: Floating-point `Tensor` broadcastable wi...
[ "Multinomial", "coefficient", "." ]
tensorflow/probability
python
https://github.com/tensorflow/probability/blob/e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5/tensorflow_probability/python/internal/distribution_util.py#L1101-L1133
[ "def", "log_combinations", "(", "n", ",", "counts", ",", "name", "=", "\"log_combinations\"", ")", ":", "# First a bit about the number of ways counts could have come in:", "# E.g. if counts = [1, 2], then this is 3 choose 2.", "# In general, this is (sum counts)! / sum(counts!)", "# T...
e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5
test
matrix_diag_transform
Transform diagonal of [batch-]matrix, leave rest of matrix unchanged. Create a trainable covariance defined by a Cholesky factor: ```python # Transform network layer into 2 x 2 array. matrix_values = tf.contrib.layers.fully_connected(activations, 4) matrix = tf.reshape(matrix_values, (batch_size, 2, 2)) ...
tensorflow_probability/python/internal/distribution_util.py
def matrix_diag_transform(matrix, transform=None, name=None): """Transform diagonal of [batch-]matrix, leave rest of matrix unchanged. Create a trainable covariance defined by a Cholesky factor: ```python # Transform network layer into 2 x 2 array. matrix_values = tf.contrib.layers.fully_connected(activatio...
def matrix_diag_transform(matrix, transform=None, name=None): """Transform diagonal of [batch-]matrix, leave rest of matrix unchanged. Create a trainable covariance defined by a Cholesky factor: ```python # Transform network layer into 2 x 2 array. matrix_values = tf.contrib.layers.fully_connected(activatio...
[ "Transform", "diagonal", "of", "[", "batch", "-", "]", "matrix", "leave", "rest", "of", "matrix", "unchanged", "." ]
tensorflow/probability
python
https://github.com/tensorflow/probability/blob/e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5/tensorflow_probability/python/internal/distribution_util.py#L1136-L1195
[ "def", "matrix_diag_transform", "(", "matrix", ",", "transform", "=", "None", ",", "name", "=", "None", ")", ":", "with", "tf", ".", "name_scope", "(", "name", "or", "\"matrix_diag_transform\"", ")", ":", "matrix", "=", "tf", ".", "convert_to_tensor", "(", ...
e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5
test
rotate_transpose
Circularly moves dims left or right. Effectively identical to: ```python numpy.transpose(x, numpy.roll(numpy.arange(len(x.shape)), shift)) ``` When `validate_args=False` additional graph-runtime checks are performed. These checks entail moving data from to GPU to CPU. Example: ```python x = tf.ra...
tensorflow_probability/python/internal/distribution_util.py
def rotate_transpose(x, shift, name="rotate_transpose"): """Circularly moves dims left or right. Effectively identical to: ```python numpy.transpose(x, numpy.roll(numpy.arange(len(x.shape)), shift)) ``` When `validate_args=False` additional graph-runtime checks are performed. These checks entail moving...
def rotate_transpose(x, shift, name="rotate_transpose"): """Circularly moves dims left or right. Effectively identical to: ```python numpy.transpose(x, numpy.roll(numpy.arange(len(x.shape)), shift)) ``` When `validate_args=False` additional graph-runtime checks are performed. These checks entail moving...
[ "Circularly", "moves", "dims", "left", "or", "right", "." ]
tensorflow/probability
python
https://github.com/tensorflow/probability/blob/e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5/tensorflow_probability/python/internal/distribution_util.py#L1198-L1271
[ "def", "rotate_transpose", "(", "x", ",", "shift", ",", "name", "=", "\"rotate_transpose\"", ")", ":", "with", "tf", ".", "name_scope", "(", "name", ")", ":", "x", "=", "tf", ".", "convert_to_tensor", "(", "value", "=", "x", ",", "name", "=", "\"x\"", ...
e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5
test
pick_vector
Picks possibly different length row `Tensor`s based on condition. Value `Tensor`s should have exactly one dimension. If `cond` is a python Boolean or `tf.constant` then either `true_vector` or `false_vector` is immediately returned. I.e., no graph nodes are created and no validation happens. Args: cond...
tensorflow_probability/python/internal/distribution_util.py
def pick_vector(cond, true_vector, false_vector, name="pick_vector"): """Picks possibly different length row `Tensor`s based on condition. Value `Tensor`s should have exactly one dimension. If `cond` is a python Boolean or `tf.constant` then either `true_vector` or `false_vector` is immediately returned. I.e....
def pick_vector(cond, true_vector, false_vector, name="pick_vector"): """Picks possibly different length row `Tensor`s based on condition. Value `Tensor`s should have exactly one dimension. If `cond` is a python Boolean or `tf.constant` then either `true_vector` or `false_vector` is immediately returned. I.e....
[ "Picks", "possibly", "different", "length", "row", "Tensor", "s", "based", "on", "condition", "." ]
tensorflow/probability
python
https://github.com/tensorflow/probability/blob/e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5/tensorflow_probability/python/internal/distribution_util.py#L1274-L1320
[ "def", "pick_vector", "(", "cond", ",", "true_vector", ",", "false_vector", ",", "name", "=", "\"pick_vector\"", ")", ":", "with", "tf", ".", "name_scope", "(", "name", ")", ":", "cond", "=", "tf", ".", "convert_to_tensor", "(", "value", "=", "cond", ","...
e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5
test
prefer_static_broadcast_shape
Convenience function which statically broadcasts shape when possible. Args: shape1: `1-D` integer `Tensor`. Already converted to tensor! shape2: `1-D` integer `Tensor`. Already converted to tensor! name: A string name to prepend to created ops. Returns: The broadcast shape, either as `TensorS...
tensorflow_probability/python/internal/distribution_util.py
def prefer_static_broadcast_shape(shape1, shape2, name="prefer_static_broadcast_shape"): """Convenience function which statically broadcasts shape when possible. Args: shape1: `1-D` integer `Tensor`. Already converted to tensor! shape2: ...
def prefer_static_broadcast_shape(shape1, shape2, name="prefer_static_broadcast_shape"): """Convenience function which statically broadcasts shape when possible. Args: shape1: `1-D` integer `Tensor`. Already converted to tensor! shape2: ...
[ "Convenience", "function", "which", "statically", "broadcasts", "shape", "when", "possible", "." ]
tensorflow/probability
python
https://github.com/tensorflow/probability/blob/e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5/tensorflow_probability/python/internal/distribution_util.py#L1323-L1365
[ "def", "prefer_static_broadcast_shape", "(", "shape1", ",", "shape2", ",", "name", "=", "\"prefer_static_broadcast_shape\"", ")", ":", "with", "tf", ".", "name_scope", "(", "name", ")", ":", "def", "make_shape_tensor", "(", "x", ")", ":", "return", "tf", ".", ...
e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5
test
gen_new_seed
Generate a new seed, from the given seed and salt.
tensorflow_probability/python/internal/distribution_util.py
def gen_new_seed(seed, salt): """Generate a new seed, from the given seed and salt.""" if seed is None: return None string = (str(seed) + salt).encode("utf-8") return int(hashlib.md5(string).hexdigest()[:8], 16) & 0x7FFFFFFF
def gen_new_seed(seed, salt): """Generate a new seed, from the given seed and salt.""" if seed is None: return None string = (str(seed) + salt).encode("utf-8") return int(hashlib.md5(string).hexdigest()[:8], 16) & 0x7FFFFFFF
[ "Generate", "a", "new", "seed", "from", "the", "given", "seed", "and", "salt", "." ]
tensorflow/probability
python
https://github.com/tensorflow/probability/blob/e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5/tensorflow_probability/python/internal/distribution_util.py#L1407-L1412
[ "def", "gen_new_seed", "(", "seed", ",", "salt", ")", ":", "if", "seed", "is", "None", ":", "return", "None", "string", "=", "(", "str", "(", "seed", ")", "+", "salt", ")", ".", "encode", "(", "\"utf-8\"", ")", "return", "int", "(", "hashlib", ".",...
e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5
test
fill_triangular
r"""Creates a (batch of) triangular matrix from a vector of inputs. Created matrix can be lower- or upper-triangular. (It is more efficient to create the matrix as upper or lower, rather than transpose.) Triangular matrix elements are filled in a clockwise spiral. See example, below. If `x.shape` is `[b1, ...
tensorflow_probability/python/internal/distribution_util.py
def fill_triangular(x, upper=False, name=None): r"""Creates a (batch of) triangular matrix from a vector of inputs. Created matrix can be lower- or upper-triangular. (It is more efficient to create the matrix as upper or lower, rather than transpose.) Triangular matrix elements are filled in a clockwise spira...
def fill_triangular(x, upper=False, name=None): r"""Creates a (batch of) triangular matrix from a vector of inputs. Created matrix can be lower- or upper-triangular. (It is more efficient to create the matrix as upper or lower, rather than transpose.) Triangular matrix elements are filled in a clockwise spira...
[ "r", "Creates", "a", "(", "batch", "of", ")", "triangular", "matrix", "from", "a", "vector", "of", "inputs", "." ]
tensorflow/probability
python
https://github.com/tensorflow/probability/blob/e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5/tensorflow_probability/python/internal/distribution_util.py#L1415-L1561
[ "def", "fill_triangular", "(", "x", ",", "upper", "=", "False", ",", "name", "=", "None", ")", ":", "with", "tf", ".", "name_scope", "(", "name", "or", "\"fill_triangular\"", ")", ":", "x", "=", "tf", ".", "convert_to_tensor", "(", "value", "=", "x", ...
e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5
test
fill_triangular_inverse
Creates a vector from a (batch of) triangular matrix. The vector is created from the lower-triangular or upper-triangular portion depending on the value of the parameter `upper`. If `x.shape` is `[b1, b2, ..., bB, n, n]` then the output shape is `[b1, b2, ..., bB, d]` where `d = n (n + 1) / 2`. Example: ...
tensorflow_probability/python/internal/distribution_util.py
def fill_triangular_inverse(x, upper=False, name=None): """Creates a vector from a (batch of) triangular matrix. The vector is created from the lower-triangular or upper-triangular portion depending on the value of the parameter `upper`. If `x.shape` is `[b1, b2, ..., bB, n, n]` then the output shape is `[b...
def fill_triangular_inverse(x, upper=False, name=None): """Creates a vector from a (batch of) triangular matrix. The vector is created from the lower-triangular or upper-triangular portion depending on the value of the parameter `upper`. If `x.shape` is `[b1, b2, ..., bB, n, n]` then the output shape is `[b...
[ "Creates", "a", "vector", "from", "a", "(", "batch", "of", ")", "triangular", "matrix", "." ]
tensorflow/probability
python
https://github.com/tensorflow/probability/blob/e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5/tensorflow_probability/python/internal/distribution_util.py#L1564-L1630
[ "def", "fill_triangular_inverse", "(", "x", ",", "upper", "=", "False", ",", "name", "=", "None", ")", ":", "with", "tf", ".", "name_scope", "(", "name", "or", "\"fill_triangular_inverse\"", ")", ":", "x", "=", "tf", ".", "convert_to_tensor", "(", "value",...
e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5
test
tridiag
Creates a matrix with values set above, below, and on the diagonal. Example: ```python tridiag(below=[1., 2., 3.], diag=[4., 5., 6., 7.], above=[8., 9., 10.]) # ==> array([[ 4., 8., 0., 0.], # [ 1., 5., 9., 0.], # [ 0., 2., 6., 10.], # ...
tensorflow_probability/python/internal/distribution_util.py
def tridiag(below=None, diag=None, above=None, name=None): """Creates a matrix with values set above, below, and on the diagonal. Example: ```python tridiag(below=[1., 2., 3.], diag=[4., 5., 6., 7.], above=[8., 9., 10.]) # ==> array([[ 4., 8., 0., 0.], # [ 1., 5., ...
def tridiag(below=None, diag=None, above=None, name=None): """Creates a matrix with values set above, below, and on the diagonal. Example: ```python tridiag(below=[1., 2., 3.], diag=[4., 5., 6., 7.], above=[8., 9., 10.]) # ==> array([[ 4., 8., 0., 0.], # [ 1., 5., ...
[ "Creates", "a", "matrix", "with", "values", "set", "above", "below", "and", "on", "the", "diagonal", "." ]
tensorflow/probability
python
https://github.com/tensorflow/probability/blob/e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5/tensorflow_probability/python/internal/distribution_util.py#L1633-L1698
[ "def", "tridiag", "(", "below", "=", "None", ",", "diag", "=", "None", ",", "above", "=", "None", ",", "name", "=", "None", ")", ":", "def", "_pad", "(", "x", ")", ":", "\"\"\"Prepends and appends a zero to every vector in a batch of vectors.\"\"\"", "shape", ...
e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5
test
reduce_weighted_logsumexp
Computes `log(abs(sum(weight * exp(elements across tensor dimensions))))`. If all weights `w` are known to be positive, it is more efficient to directly use `reduce_logsumexp`, i.e., `tf.reduce_logsumexp(logx + tf.log(w))` is more efficient than `du.reduce_weighted_logsumexp(logx, w)`. Reduces `input_tensor` ...
tensorflow_probability/python/internal/distribution_util.py
def reduce_weighted_logsumexp(logx, w=None, axis=None, keep_dims=False, return_sign=False, name=None): """Computes `log(abs(sum(weight * exp(elements across tensor dime...
def reduce_weighted_logsumexp(logx, w=None, axis=None, keep_dims=False, return_sign=False, name=None): """Computes `log(abs(sum(weight * exp(elements across tensor dime...
[ "Computes", "log", "(", "abs", "(", "sum", "(", "weight", "*", "exp", "(", "elements", "across", "tensor", "dimensions", "))))", "." ]
tensorflow/probability
python
https://github.com/tensorflow/probability/blob/e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5/tensorflow_probability/python/internal/distribution_util.py#L1701-L1793
[ "def", "reduce_weighted_logsumexp", "(", "logx", ",", "w", "=", "None", ",", "axis", "=", "None", ",", "keep_dims", "=", "False", ",", "return_sign", "=", "False", ",", "name", "=", "None", ")", ":", "with", "tf", ".", "name_scope", "(", "name", "or", ...
e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5
test
softplus_inverse
Computes the inverse softplus, i.e., x = softplus_inverse(softplus(x)). Mathematically this op is equivalent to: ```none softplus_inverse = log(exp(x) - 1.) ``` Args: x: `Tensor`. Non-negative (not enforced), floating-point. name: A name for the operation (optional). Returns: `Tensor`. Has t...
tensorflow_probability/python/internal/distribution_util.py
def softplus_inverse(x, name=None): """Computes the inverse softplus, i.e., x = softplus_inverse(softplus(x)). Mathematically this op is equivalent to: ```none softplus_inverse = log(exp(x) - 1.) ``` Args: x: `Tensor`. Non-negative (not enforced), floating-point. name: A name for the operation (o...
def softplus_inverse(x, name=None): """Computes the inverse softplus, i.e., x = softplus_inverse(softplus(x)). Mathematically this op is equivalent to: ```none softplus_inverse = log(exp(x) - 1.) ``` Args: x: `Tensor`. Non-negative (not enforced), floating-point. name: A name for the operation (o...
[ "Computes", "the", "inverse", "softplus", "i", ".", "e", ".", "x", "=", "softplus_inverse", "(", "softplus", "(", "x", "))", "." ]
tensorflow/probability
python
https://github.com/tensorflow/probability/blob/e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5/tensorflow_probability/python/internal/distribution_util.py#L1799-L1849
[ "def", "softplus_inverse", "(", "x", ",", "name", "=", "None", ")", ":", "with", "tf", ".", "name_scope", "(", "name", "or", "\"softplus_inverse\"", ")", ":", "x", "=", "tf", ".", "convert_to_tensor", "(", "value", "=", "x", ",", "name", "=", "\"x\"", ...
e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5
test
dimension_size
Returns the size of a specific dimension.
tensorflow_probability/python/internal/distribution_util.py
def dimension_size(x, axis): """Returns the size of a specific dimension.""" # Since tf.gather isn't "constant-in, constant-out", we must first check the # static shape or fallback to dynamic shape. s = tf.compat.dimension_value( tensorshape_util.with_rank_at_least(x.shape, np.abs(axis))[axis]) if s is ...
def dimension_size(x, axis): """Returns the size of a specific dimension.""" # Since tf.gather isn't "constant-in, constant-out", we must first check the # static shape or fallback to dynamic shape. s = tf.compat.dimension_value( tensorshape_util.with_rank_at_least(x.shape, np.abs(axis))[axis]) if s is ...
[ "Returns", "the", "size", "of", "a", "specific", "dimension", "." ]
tensorflow/probability
python
https://github.com/tensorflow/probability/blob/e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5/tensorflow_probability/python/internal/distribution_util.py#L1853-L1861
[ "def", "dimension_size", "(", "x", ",", "axis", ")", ":", "# Since tf.gather isn't \"constant-in, constant-out\", we must first check the", "# static shape or fallback to dynamic shape.", "s", "=", "tf", ".", "compat", ".", "dimension_value", "(", "tensorshape_util", ".", "wi...
e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5
test
process_quadrature_grid_and_probs
Validates quadrature grid, probs or computes them as necessary. Args: quadrature_grid_and_probs: Python pair of `float`-like `Tensor`s representing the sample points and the corresponding (possibly normalized) weight. When `None`, defaults to: `np.polynomial.hermite.hermgauss(deg=8)`. dt...
tensorflow_probability/python/internal/distribution_util.py
def process_quadrature_grid_and_probs(quadrature_grid_and_probs, dtype, validate_args, name=None): """Validates quadrature grid, probs or computes them as necessary. Args: quadrature_grid_and_probs...
def process_quadrature_grid_and_probs(quadrature_grid_and_probs, dtype, validate_args, name=None): """Validates quadrature grid, probs or computes them as necessary. Args: quadrature_grid_and_probs...
[ "Validates", "quadrature", "grid", "probs", "or", "computes", "them", "as", "necessary", "." ]
tensorflow/probability
python
https://github.com/tensorflow/probability/blob/e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5/tensorflow_probability/python/internal/distribution_util.py#L1864-L1929
[ "def", "process_quadrature_grid_and_probs", "(", "quadrature_grid_and_probs", ",", "dtype", ",", "validate_args", ",", "name", "=", "None", ")", ":", "with", "tf", ".", "name_scope", "(", "name", "or", "\"process_quadrature_grid_and_probs\"", ")", ":", "if", "quadra...
e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5
test
pad
Pads `value` to the front and/or back of a `Tensor` dim, `count` times. Args: x: `Tensor` input. axis: Scalar `int`-like `Tensor` representing the single dimension to pad. (Negative indexing is supported.) front: Python `bool`; if `True` the beginning of the `axis` dimension is padded with `v...
tensorflow_probability/python/internal/distribution_util.py
def pad(x, axis, front=False, back=False, value=0, count=1, name=None): """Pads `value` to the front and/or back of a `Tensor` dim, `count` times. Args: x: `Tensor` input. axis: Scalar `int`-like `Tensor` representing the single dimension to pad. (Negative indexing is supported.) front: Python `b...
def pad(x, axis, front=False, back=False, value=0, count=1, name=None): """Pads `value` to the front and/or back of a `Tensor` dim, `count` times. Args: x: `Tensor` input. axis: Scalar `int`-like `Tensor` representing the single dimension to pad. (Negative indexing is supported.) front: Python `b...
[ "Pads", "value", "to", "the", "front", "and", "/", "or", "back", "of", "a", "Tensor", "dim", "count", "times", "." ]
tensorflow/probability
python
https://github.com/tensorflow/probability/blob/e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5/tensorflow_probability/python/internal/distribution_util.py#L1932-L2002
[ "def", "pad", "(", "x", ",", "axis", ",", "front", "=", "False", ",", "back", "=", "False", ",", "value", "=", "0", ",", "count", "=", "1", ",", "name", "=", "None", ")", ":", "with", "tf", ".", "name_scope", "(", "name", "or", "\"pad\"", ")", ...
e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5
test
parent_frame_arguments
Returns parent frame arguments. When called inside a function, returns a dictionary with the caller's function arguments. These are positional arguments and keyword arguments (**kwargs), while variable arguments (*varargs) are excluded. When called at global scope, this will return an empty dictionary, since ...
tensorflow_probability/python/internal/distribution_util.py
def parent_frame_arguments(): """Returns parent frame arguments. When called inside a function, returns a dictionary with the caller's function arguments. These are positional arguments and keyword arguments (**kwargs), while variable arguments (*varargs) are excluded. When called at global scope, this will...
def parent_frame_arguments(): """Returns parent frame arguments. When called inside a function, returns a dictionary with the caller's function arguments. These are positional arguments and keyword arguments (**kwargs), while variable arguments (*varargs) are excluded. When called at global scope, this will...
[ "Returns", "parent", "frame", "arguments", "." ]
tensorflow/probability
python
https://github.com/tensorflow/probability/blob/e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5/tensorflow_probability/python/internal/distribution_util.py#L2005-L2039
[ "def", "parent_frame_arguments", "(", ")", ":", "# All arguments and the names used for *varargs, and **kwargs", "arg_names", ",", "variable_arg_name", ",", "keyword_arg_name", ",", "local_vars", "=", "(", "tf_inspect", ".", "_inspect", ".", "getargvalues", "(", "# pylint: ...
e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5
test
expand_to_vector
Transform a 0-D or 1-D `Tensor` to be 1-D. For user convenience, many parts of the TensorFlow Probability API accept inputs of rank 0 or 1 -- i.e., allowing an `event_shape` of `[5]` to be passed to the API as either `5` or `[5]`. This function can be used to transform such an argument to always be 1-D. NO...
tensorflow_probability/python/internal/distribution_util.py
def expand_to_vector(x, tensor_name=None, op_name=None, validate_args=False): """Transform a 0-D or 1-D `Tensor` to be 1-D. For user convenience, many parts of the TensorFlow Probability API accept inputs of rank 0 or 1 -- i.e., allowing an `event_shape` of `[5]` to be passed to the API as either `5` or `[5]`....
def expand_to_vector(x, tensor_name=None, op_name=None, validate_args=False): """Transform a 0-D or 1-D `Tensor` to be 1-D. For user convenience, many parts of the TensorFlow Probability API accept inputs of rank 0 or 1 -- i.e., allowing an `event_shape` of `[5]` to be passed to the API as either `5` or `[5]`....
[ "Transform", "a", "0", "-", "D", "or", "1", "-", "D", "Tensor", "to", "be", "1", "-", "D", "." ]
tensorflow/probability
python
https://github.com/tensorflow/probability/blob/e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5/tensorflow_probability/python/internal/distribution_util.py#L2103-L2159
[ "def", "expand_to_vector", "(", "x", ",", "tensor_name", "=", "None", ",", "op_name", "=", "None", ",", "validate_args", "=", "False", ")", ":", "with", "tf", ".", "name_scope", "(", "op_name", "or", "\"expand_to_vector\"", ")", ":", "x", "=", "tf", ".",...
e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5
test
with_dependencies
Produces the content of `output_tensor` only after `dependencies`. In some cases, a user may want the output of an operation to be consumed externally only after some other dependencies have run first. This function returns `output_tensor`, but only after all operations in `dependencies` have run. Note that th...
tensorflow_probability/python/internal/distribution_util.py
def with_dependencies(dependencies, output_tensor, name=None): """Produces the content of `output_tensor` only after `dependencies`. In some cases, a user may want the output of an operation to be consumed externally only after some other dependencies have run first. This function returns `output_tensor`, but ...
def with_dependencies(dependencies, output_tensor, name=None): """Produces the content of `output_tensor` only after `dependencies`. In some cases, a user may want the output of an operation to be consumed externally only after some other dependencies have run first. This function returns `output_tensor`, but ...
[ "Produces", "the", "content", "of", "output_tensor", "only", "after", "dependencies", "." ]
tensorflow/probability
python
https://github.com/tensorflow/probability/blob/e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5/tensorflow_probability/python/internal/distribution_util.py#L2162-L2195
[ "def", "with_dependencies", "(", "dependencies", ",", "output_tensor", ",", "name", "=", "None", ")", ":", "if", "tf", ".", "executing_eagerly", "(", ")", ":", "return", "output_tensor", "with", "tf", ".", "name_scope", "(", "name", "or", "\"control_dependency...
e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5
test
_maybe_validate_rightmost_transposed_ndims
Checks that `rightmost_transposed_ndims` is valid.
tensorflow_probability/python/bijectors/transpose.py
def _maybe_validate_rightmost_transposed_ndims( rightmost_transposed_ndims, validate_args, name=None): """Checks that `rightmost_transposed_ndims` is valid.""" with tf.name_scope(name or 'maybe_validate_rightmost_transposed_ndims'): assertions = [] if not dtype_util.is_integer(rightmost_transposed_ndims...
def _maybe_validate_rightmost_transposed_ndims( rightmost_transposed_ndims, validate_args, name=None): """Checks that `rightmost_transposed_ndims` is valid.""" with tf.name_scope(name or 'maybe_validate_rightmost_transposed_ndims'): assertions = [] if not dtype_util.is_integer(rightmost_transposed_ndims...
[ "Checks", "that", "rightmost_transposed_ndims", "is", "valid", "." ]
tensorflow/probability
python
https://github.com/tensorflow/probability/blob/e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5/tensorflow_probability/python/bijectors/transpose.py#L258-L288
[ "def", "_maybe_validate_rightmost_transposed_ndims", "(", "rightmost_transposed_ndims", ",", "validate_args", ",", "name", "=", "None", ")", ":", "with", "tf", ".", "name_scope", "(", "name", "or", "'maybe_validate_rightmost_transposed_ndims'", ")", ":", "assertions", "...
e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5
test
_maybe_validate_perm
Checks that `perm` is valid.
tensorflow_probability/python/bijectors/transpose.py
def _maybe_validate_perm(perm, validate_args, name=None): """Checks that `perm` is valid.""" with tf.name_scope(name or 'maybe_validate_perm'): assertions = [] if not dtype_util.is_integer(perm.dtype): raise TypeError('`perm` must be integer type') msg = '`perm` must be a vector.' if tensorsh...
def _maybe_validate_perm(perm, validate_args, name=None): """Checks that `perm` is valid.""" with tf.name_scope(name or 'maybe_validate_perm'): assertions = [] if not dtype_util.is_integer(perm.dtype): raise TypeError('`perm` must be integer type') msg = '`perm` must be a vector.' if tensorsh...
[ "Checks", "that", "perm", "is", "valid", "." ]
tensorflow/probability
python
https://github.com/tensorflow/probability/blob/e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5/tensorflow_probability/python/bijectors/transpose.py#L291-L318
[ "def", "_maybe_validate_perm", "(", "perm", ",", "validate_args", ",", "name", "=", "None", ")", ":", "with", "tf", ".", "name_scope", "(", "name", "or", "'maybe_validate_perm'", ")", ":", "assertions", "=", "[", "]", "if", "not", "dtype_util", ".", "is_in...
e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5
test
Transpose._event_shape
Helper for _forward and _inverse_event_shape.
tensorflow_probability/python/bijectors/transpose.py
def _event_shape(self, shape, static_perm_to_shape): """Helper for _forward and _inverse_event_shape.""" rightmost_ = tf.get_static_value(self.rightmost_transposed_ndims) if tensorshape_util.rank(shape) is None or rightmost_ is None: return tf.TensorShape(None) if tensorshape_util.rank(shape) < ri...
def _event_shape(self, shape, static_perm_to_shape): """Helper for _forward and _inverse_event_shape.""" rightmost_ = tf.get_static_value(self.rightmost_transposed_ndims) if tensorshape_util.rank(shape) is None or rightmost_ is None: return tf.TensorShape(None) if tensorshape_util.rank(shape) < ri...
[ "Helper", "for", "_forward", "and", "_inverse_event_shape", "." ]
tensorflow/probability
python
https://github.com/tensorflow/probability/blob/e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5/tensorflow_probability/python/bijectors/transpose.py#L184-L205
[ "def", "_event_shape", "(", "self", ",", "shape", ",", "static_perm_to_shape", ")", ":", "rightmost_", "=", "tf", ".", "get_static_value", "(", "self", ".", "rightmost_transposed_ndims", ")", "if", "tensorshape_util", ".", "rank", "(", "shape", ")", "is", "Non...
e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5
test
concatenate
Returns the concatenation of the dimension in `x` and `other`. *Note:* If either `x` or `other` is completely unknown, concatenation will discard information about the other shape. In future, we might support concatenation that preserves this information for use with slicing. For more details, see `help(tf.Te...
tensorflow_probability/python/internal/tensorshape_util.py
def concatenate(x, other): """Returns the concatenation of the dimension in `x` and `other`. *Note:* If either `x` or `other` is completely unknown, concatenation will discard information about the other shape. In future, we might support concatenation that preserves this information for use with slicing. F...
def concatenate(x, other): """Returns the concatenation of the dimension in `x` and `other`. *Note:* If either `x` or `other` is completely unknown, concatenation will discard information about the other shape. In future, we might support concatenation that preserves this information for use with slicing. F...
[ "Returns", "the", "concatenation", "of", "the", "dimension", "in", "x", "and", "other", "." ]
tensorflow/probability
python
https://github.com/tensorflow/probability/blob/e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5/tensorflow_probability/python/internal/tensorshape_util.py#L99-L116
[ "def", "concatenate", "(", "x", ",", "other", ")", ":", "return", "type", "(", "x", ")", "(", "tf", ".", "TensorShape", "(", "x", ")", ".", "concatenate", "(", "other", ")", ")" ]
e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5
test
constant_value_as_shape
A version of `constant_value()` that returns a `TensorShape`. This version should be used when a constant tensor value is interpreted as a (possibly partial) shape, e.g. in the shape function for `tf.reshape()`. By explicitly requesting a `TensorShape` as the return value, it is possible to represent unknown...
tensorflow_probability/python/internal/tensorshape_util.py
def constant_value_as_shape(tensor): # pylint: disable=invalid-name """A version of `constant_value()` that returns a `TensorShape`. This version should be used when a constant tensor value is interpreted as a (possibly partial) shape, e.g. in the shape function for `tf.reshape()`. By explicitly requesting a ...
def constant_value_as_shape(tensor): # pylint: disable=invalid-name """A version of `constant_value()` that returns a `TensorShape`. This version should be used when a constant tensor value is interpreted as a (possibly partial) shape, e.g. in the shape function for `tf.reshape()`. By explicitly requesting a ...
[ "A", "version", "of", "constant_value", "()", "that", "returns", "a", "TensorShape", "." ]
tensorflow/probability
python
https://github.com/tensorflow/probability/blob/e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5/tensorflow_probability/python/internal/tensorshape_util.py#L119-L141
[ "def", "constant_value_as_shape", "(", "tensor", ")", ":", "# pylint: disable=invalid-name", "shape", "=", "tf", ".", "get_static_value", "(", "tensor", ")", "if", "shape", "is", "not", "None", ":", "return", "[", "None", "if", "dim", "==", "-", "1", "else",...
e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5
test
dims
Returns a list of dimension sizes, or `None` if `rank` is unknown. For more details, see `help(tf.TensorShape.dims)`. Args: x: object representing a shape; convertible to `tf.TensorShape`. Returns: shape_as_list: list of sizes or `None` values representing each dimensions size if known. A size is...
tensorflow_probability/python/internal/tensorshape_util.py
def dims(x): """Returns a list of dimension sizes, or `None` if `rank` is unknown. For more details, see `help(tf.TensorShape.dims)`. Args: x: object representing a shape; convertible to `tf.TensorShape`. Returns: shape_as_list: list of sizes or `None` values representing each dimensions size i...
def dims(x): """Returns a list of dimension sizes, or `None` if `rank` is unknown. For more details, see `help(tf.TensorShape.dims)`. Args: x: object representing a shape; convertible to `tf.TensorShape`. Returns: shape_as_list: list of sizes or `None` values representing each dimensions size i...
[ "Returns", "a", "list", "of", "dimension", "sizes", "or", "None", "if", "rank", "is", "unknown", "." ]
tensorflow/probability
python
https://github.com/tensorflow/probability/blob/e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5/tensorflow_probability/python/internal/tensorshape_util.py#L144-L160
[ "def", "dims", "(", "x", ")", ":", "if", "isinstance", "(", "x", ",", "tf", ".", "TensorShape", ")", ":", "return", "x", ".", "dims", "r", "=", "tf", ".", "TensorShape", "(", "x", ")", ".", "dims", "return", "None", "if", "r", "is", "None", "el...
e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5
test
merge_with
Returns a shape combining the information in `x` and `other`. The dimensions in `x` and `other` are merged elementwise, according to the rules defined for `tf.Dimension.merge_with()`. For more details, see `help(tf.TensorShape.merge_with)`. Args: x: object representing a shape; convertible to `tf.TensorS...
tensorflow_probability/python/internal/tensorshape_util.py
def merge_with(x, other): """Returns a shape combining the information in `x` and `other`. The dimensions in `x` and `other` are merged elementwise, according to the rules defined for `tf.Dimension.merge_with()`. For more details, see `help(tf.TensorShape.merge_with)`. Args: x: object representing a sh...
def merge_with(x, other): """Returns a shape combining the information in `x` and `other`. The dimensions in `x` and `other` are merged elementwise, according to the rules defined for `tf.Dimension.merge_with()`. For more details, see `help(tf.TensorShape.merge_with)`. Args: x: object representing a sh...
[ "Returns", "a", "shape", "combining", "the", "information", "in", "x", "and", "other", "." ]
tensorflow/probability
python
https://github.com/tensorflow/probability/blob/e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5/tensorflow_probability/python/internal/tensorshape_util.py#L192-L211
[ "def", "merge_with", "(", "x", ",", "other", ")", ":", "return", "type", "(", "x", ")", "(", "tf", ".", "TensorShape", "(", "x", ")", ".", "merge_with", "(", "other", ")", ")" ]
e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5
test
with_rank_at_least
Returns a shape based on `x` with at least the given `rank`. For more details, see `help(tf.TensorShape.with_rank_at_least)`. Args: x: object representing a shape; convertible to `tf.TensorShape`. rank: An `int` representing the minimum rank of `x` or else an assertion is raised. Returns: sha...
tensorflow_probability/python/internal/tensorshape_util.py
def with_rank_at_least(x, rank): # pylint: disable=redefined-outer-name """Returns a shape based on `x` with at least the given `rank`. For more details, see `help(tf.TensorShape.with_rank_at_least)`. Args: x: object representing a shape; convertible to `tf.TensorShape`. rank: An `int` representing the...
def with_rank_at_least(x, rank): # pylint: disable=redefined-outer-name """Returns a shape based on `x` with at least the given `rank`. For more details, see `help(tf.TensorShape.with_rank_at_least)`. Args: x: object representing a shape; convertible to `tf.TensorShape`. rank: An `int` representing the...
[ "Returns", "a", "shape", "based", "on", "x", "with", "at", "least", "the", "given", "rank", "." ]
tensorflow/probability
python
https://github.com/tensorflow/probability/blob/e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5/tensorflow_probability/python/internal/tensorshape_util.py#L285-L303
[ "def", "with_rank_at_least", "(", "x", ",", "rank", ")", ":", "# pylint: disable=redefined-outer-name", "return", "type", "(", "x", ")", "(", "tf", ".", "TensorShape", "(", "x", ")", ".", "with_rank_at_least", "(", "rank", ")", ")" ]
e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5
test
_check_equal_shape
Check that source and target shape match, statically if possible.
tensorflow_probability/python/distributions/linear_gaussian_ssm.py
def _check_equal_shape(name, static_shape, dynamic_shape, static_target_shape, dynamic_target_shape=None): """Check that source and target shape match, statically if possible.""" static_target_shape = tf.TensorShape(static_...
def _check_equal_shape(name, static_shape, dynamic_shape, static_target_shape, dynamic_target_shape=None): """Check that source and target shape match, statically if possible.""" static_target_shape = tf.TensorShape(static_...
[ "Check", "that", "source", "and", "target", "shape", "match", "statically", "if", "possible", "." ]
tensorflow/probability
python
https://github.com/tensorflow/probability/blob/e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5/tensorflow_probability/python/distributions/linear_gaussian_ssm.py#L44-L69
[ "def", "_check_equal_shape", "(", "name", ",", "static_shape", ",", "dynamic_shape", ",", "static_target_shape", ",", "dynamic_target_shape", "=", "None", ")", ":", "static_target_shape", "=", "tf", ".", "TensorShape", "(", "static_target_shape", ")", "if", "tensors...
e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5
test
_augment_sample_shape
Augment a sample shape to broadcast batch dimensions. Computes an augmented sample shape, so that any batch dimensions not part of the distribution `partial_batch_dist` are treated as identical distributions. # partial_batch_dist.batch_shape = [ 7] # full_sample_and_batch_shape = [3, 4, 7] # => ...
tensorflow_probability/python/distributions/linear_gaussian_ssm.py
def _augment_sample_shape(partial_batch_dist, full_sample_and_batch_shape, validate_args=False): """Augment a sample shape to broadcast batch dimensions. Computes an augmented sample shape, so that any batch dimensions not part of the distribution `partial_batc...
def _augment_sample_shape(partial_batch_dist, full_sample_and_batch_shape, validate_args=False): """Augment a sample shape to broadcast batch dimensions. Computes an augmented sample shape, so that any batch dimensions not part of the distribution `partial_batc...
[ "Augment", "a", "sample", "shape", "to", "broadcast", "batch", "dimensions", "." ]
tensorflow/probability
python
https://github.com/tensorflow/probability/blob/e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5/tensorflow_probability/python/distributions/linear_gaussian_ssm.py#L72-L155
[ "def", "_augment_sample_shape", "(", "partial_batch_dist", ",", "full_sample_and_batch_shape", ",", "validate_args", "=", "False", ")", ":", "full_ndims", "=", "distribution_util", ".", "prefer_static_shape", "(", "full_sample_and_batch_shape", ")", "[", "0", "]", "part...
e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5
test
build_backward_pass_step
Build a callable that perform one step for backward smoothing. Args: get_transition_matrix_for_timestep: callable taking a timestep as an integer `Tensor` argument, and returning a `LinearOperator` of shape `[latent_size, latent_size]`. Returns: backward_pass_step: a callable that updates a Ba...
tensorflow_probability/python/distributions/linear_gaussian_ssm.py
def build_backward_pass_step(get_transition_matrix_for_timestep): """Build a callable that perform one step for backward smoothing. Args: get_transition_matrix_for_timestep: callable taking a timestep as an integer `Tensor` argument, and returning a `LinearOperator` of shape `[latent_size, latent_s...
def build_backward_pass_step(get_transition_matrix_for_timestep): """Build a callable that perform one step for backward smoothing. Args: get_transition_matrix_for_timestep: callable taking a timestep as an integer `Tensor` argument, and returning a `LinearOperator` of shape `[latent_size, latent_s...
[ "Build", "a", "callable", "that", "perform", "one", "step", "for", "backward", "smoothing", "." ]
tensorflow/probability
python
https://github.com/tensorflow/probability/blob/e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5/tensorflow_probability/python/distributions/linear_gaussian_ssm.py#L1158-L1195
[ "def", "build_backward_pass_step", "(", "get_transition_matrix_for_timestep", ")", ":", "def", "backward_pass_step", "(", "state", ",", "filtered_parameters", ")", ":", "\"\"\"Run a single step of backward smoothing.\"\"\"", "(", "filtered_mean", ",", "filtered_cov", ",", "pr...
e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5
test
backward_smoothing_update
Backward update for a Kalman smoother. Give the `filtered_mean` mu(t | t), `filtered_cov` sigma(t | t), `predicted_mean` mu(t+1 | t) and `predicted_cov` sigma(t+1 | t), as returns from the `forward_filter` function, as well as `next_posterior_mean` mu(t+1 | 1:T) and `next_posterior_cov` sigma(t+1 | 1:T), if ...
tensorflow_probability/python/distributions/linear_gaussian_ssm.py
def backward_smoothing_update(filtered_mean, filtered_cov, predicted_mean, predicted_cov, next_posterior_mean, next_posterior_cov, transitio...
def backward_smoothing_update(filtered_mean, filtered_cov, predicted_mean, predicted_cov, next_posterior_mean, next_posterior_cov, transitio...
[ "Backward", "update", "for", "a", "Kalman", "smoother", "." ]
tensorflow/probability
python
https://github.com/tensorflow/probability/blob/e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5/tensorflow_probability/python/distributions/linear_gaussian_ssm.py#L1198-L1272
[ "def", "backward_smoothing_update", "(", "filtered_mean", ",", "filtered_cov", ",", "predicted_mean", ",", "predicted_cov", ",", "next_posterior_mean", ",", "next_posterior_cov", ",", "transition_matrix", ")", ":", "# Compute backward Kalman gain:", "# J = F * T' * P^{-1}", "...
e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5
test
build_kalman_filter_step
Build a callable that performs one step of Kalman filtering. Args: get_transition_matrix_for_timestep: callable taking a timestep as an integer `Tensor` argument, and returning a `LinearOperator` of shape `[latent_size, latent_size]`. get_transition_noise_for_timestep: callable taking a timestep ...
tensorflow_probability/python/distributions/linear_gaussian_ssm.py
def build_kalman_filter_step(get_transition_matrix_for_timestep, get_transition_noise_for_timestep, get_observation_matrix_for_timestep, get_observation_noise_for_timestep): """Build a callable that performs one step of Kalman filt...
def build_kalman_filter_step(get_transition_matrix_for_timestep, get_transition_noise_for_timestep, get_observation_matrix_for_timestep, get_observation_noise_for_timestep): """Build a callable that performs one step of Kalman filt...
[ "Build", "a", "callable", "that", "performs", "one", "step", "of", "Kalman", "filtering", "." ]
tensorflow/probability
python
https://github.com/tensorflow/probability/blob/e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5/tensorflow_probability/python/distributions/linear_gaussian_ssm.py#L1275-L1394
[ "def", "build_kalman_filter_step", "(", "get_transition_matrix_for_timestep", ",", "get_transition_noise_for_timestep", ",", "get_observation_matrix_for_timestep", ",", "get_observation_noise_for_timestep", ")", ":", "def", "kalman_filter_step", "(", "state", ",", "elems_t", ")",...
e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5
test
linear_gaussian_update
Conjugate update for a linear Gaussian model. Given a normal prior on a latent variable `z`, `p(z) = N(prior_mean, prior_cov) = N(u, P)`, for which we observe a linear Gaussian transformation `x`, `p(x|z) = N(H * z + c, R)`, the posterior is also normal: `p(z|x) = N(u*, P*)`. We can write this upd...
tensorflow_probability/python/distributions/linear_gaussian_ssm.py
def linear_gaussian_update( prior_mean, prior_cov, observation_matrix, observation_noise, x_observed): """Conjugate update for a linear Gaussian model. Given a normal prior on a latent variable `z`, `p(z) = N(prior_mean, prior_cov) = N(u, P)`, for which we observe a linear Gaussian transformation `x`, ...
def linear_gaussian_update( prior_mean, prior_cov, observation_matrix, observation_noise, x_observed): """Conjugate update for a linear Gaussian model. Given a normal prior on a latent variable `z`, `p(z) = N(prior_mean, prior_cov) = N(u, P)`, for which we observe a linear Gaussian transformation `x`, ...
[ "Conjugate", "update", "for", "a", "linear", "Gaussian", "model", "." ]
tensorflow/probability
python
https://github.com/tensorflow/probability/blob/e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5/tensorflow_probability/python/distributions/linear_gaussian_ssm.py#L1397-L1519
[ "def", "linear_gaussian_update", "(", "prior_mean", ",", "prior_cov", ",", "observation_matrix", ",", "observation_noise", ",", "x_observed", ")", ":", "# If observations are scalar, we can avoid some matrix ops.", "observation_size_is_static_and_scalar", "=", "(", "tf", ".", ...
e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5
test
kalman_transition
Propagate a filtered distribution through a transition model.
tensorflow_probability/python/distributions/linear_gaussian_ssm.py
def kalman_transition(filtered_mean, filtered_cov, transition_matrix, transition_noise): """Propagate a filtered distribution through a transition model.""" predicted_mean = _propagate_mean(filtered_mean, transition_matrix, ...
def kalman_transition(filtered_mean, filtered_cov, transition_matrix, transition_noise): """Propagate a filtered distribution through a transition model.""" predicted_mean = _propagate_mean(filtered_mean, transition_matrix, ...
[ "Propagate", "a", "filtered", "distribution", "through", "a", "transition", "model", "." ]
tensorflow/probability
python
https://github.com/tensorflow/probability/blob/e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5/tensorflow_probability/python/distributions/linear_gaussian_ssm.py#L1522-L1532
[ "def", "kalman_transition", "(", "filtered_mean", ",", "filtered_cov", ",", "transition_matrix", ",", "transition_noise", ")", ":", "predicted_mean", "=", "_propagate_mean", "(", "filtered_mean", ",", "transition_matrix", ",", "transition_noise", ")", "predicted_cov", "...
e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5
test
build_kalman_mean_step
Build a callable that performs one step of Kalman mean recursion. Args: get_transition_matrix_for_timestep: callable taking a timestep as an integer `Tensor` argument, and returning a `LinearOperator` of shape `[latent_size, latent_size]`. get_transition_noise_for_timestep: callable taking a time...
tensorflow_probability/python/distributions/linear_gaussian_ssm.py
def build_kalman_mean_step(get_transition_matrix_for_timestep, get_transition_noise_for_timestep, get_observation_matrix_for_timestep, get_observation_noise_for_timestep): """Build a callable that performs one step of Kalman mean recursi...
def build_kalman_mean_step(get_transition_matrix_for_timestep, get_transition_noise_for_timestep, get_observation_matrix_for_timestep, get_observation_noise_for_timestep): """Build a callable that performs one step of Kalman mean recursi...
[ "Build", "a", "callable", "that", "performs", "one", "step", "of", "Kalman", "mean", "recursion", "." ]
tensorflow/probability
python
https://github.com/tensorflow/probability/blob/e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5/tensorflow_probability/python/distributions/linear_gaussian_ssm.py#L1535-L1574
[ "def", "build_kalman_mean_step", "(", "get_transition_matrix_for_timestep", ",", "get_transition_noise_for_timestep", ",", "get_observation_matrix_for_timestep", ",", "get_observation_noise_for_timestep", ")", ":", "def", "mean_step", "(", "previous_means", ",", "t", ")", ":", ...
e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5
test
build_kalman_cov_step
Build a callable for one step of Kalman covariance recursion. Args: get_transition_matrix_for_timestep: callable taking a timestep as an integer `Tensor` argument, and returning a `LinearOperator` of shape `[latent_size, latent_size]`. get_transition_noise_for_timestep: callable taking a timestep...
tensorflow_probability/python/distributions/linear_gaussian_ssm.py
def build_kalman_cov_step(get_transition_matrix_for_timestep, get_transition_noise_for_timestep, get_observation_matrix_for_timestep, get_observation_noise_for_timestep): """Build a callable for one step of Kalman covariance recursion. A...
def build_kalman_cov_step(get_transition_matrix_for_timestep, get_transition_noise_for_timestep, get_observation_matrix_for_timestep, get_observation_noise_for_timestep): """Build a callable for one step of Kalman covariance recursion. A...
[ "Build", "a", "callable", "for", "one", "step", "of", "Kalman", "covariance", "recursion", "." ]
tensorflow/probability
python
https://github.com/tensorflow/probability/blob/e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5/tensorflow_probability/python/distributions/linear_gaussian_ssm.py#L1577-L1619
[ "def", "build_kalman_cov_step", "(", "get_transition_matrix_for_timestep", ",", "get_transition_noise_for_timestep", ",", "get_observation_matrix_for_timestep", ",", "get_observation_noise_for_timestep", ")", ":", "def", "cov_step", "(", "previous_covs", ",", "t", ")", ":", "...
e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5
test
build_kalman_sample_step
Build a callable for one step of Kalman sampling recursion. Args: get_transition_matrix_for_timestep: callable taking a timestep as an integer `Tensor` argument, and returning a `LinearOperator` of shape `[latent_size, latent_size]`. get_transition_noise_for_timestep: callable taking a timestep a...
tensorflow_probability/python/distributions/linear_gaussian_ssm.py
def build_kalman_sample_step(get_transition_matrix_for_timestep, get_transition_noise_for_timestep, get_observation_matrix_for_timestep, get_observation_noise_for_timestep, full_sample_and_batch_shape, ...
def build_kalman_sample_step(get_transition_matrix_for_timestep, get_transition_noise_for_timestep, get_observation_matrix_for_timestep, get_observation_noise_for_timestep, full_sample_and_batch_shape, ...
[ "Build", "a", "callable", "for", "one", "step", "of", "Kalman", "sampling", "recursion", "." ]
tensorflow/probability
python
https://github.com/tensorflow/probability/blob/e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5/tensorflow_probability/python/distributions/linear_gaussian_ssm.py#L1622-L1685
[ "def", "build_kalman_sample_step", "(", "get_transition_matrix_for_timestep", ",", "get_transition_noise_for_timestep", ",", "get_observation_matrix_for_timestep", ",", "get_observation_noise_for_timestep", ",", "full_sample_and_batch_shape", ",", "stream", ",", "validate_args", "=",...
e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5
test
build_pushforward_latents_step
Build a callable to push latent means/covs to observed means/covs. Args: get_observation_matrix_for_timestep: callable taking a timestep as an integer `Tensor` argument, and returning a `LinearOperator` of shape `[observation_size, observation_size]`. get_observation_noise_for_timestep: callable ...
tensorflow_probability/python/distributions/linear_gaussian_ssm.py
def build_pushforward_latents_step(get_observation_matrix_for_timestep, get_observation_noise_for_timestep): """Build a callable to push latent means/covs to observed means/covs. Args: get_observation_matrix_for_timestep: callable taking a timestep as an integer `Tensor...
def build_pushforward_latents_step(get_observation_matrix_for_timestep, get_observation_noise_for_timestep): """Build a callable to push latent means/covs to observed means/covs. Args: get_observation_matrix_for_timestep: callable taking a timestep as an integer `Tensor...
[ "Build", "a", "callable", "to", "push", "latent", "means", "/", "covs", "to", "observed", "means", "/", "covs", "." ]
tensorflow/probability
python
https://github.com/tensorflow/probability/blob/e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5/tensorflow_probability/python/distributions/linear_gaussian_ssm.py#L1688-L1721
[ "def", "build_pushforward_latents_step", "(", "get_observation_matrix_for_timestep", ",", "get_observation_noise_for_timestep", ")", ":", "def", "pushforward_latents_step", "(", "_", ",", "latent_t_mean_cov", ")", ":", "\"\"\"Loop body fn to pushforward latents to observations at a t...
e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5
test
_propagate_mean
Propagate a mean through linear Gaussian transformation.
tensorflow_probability/python/distributions/linear_gaussian_ssm.py
def _propagate_mean(mean, linop, dist): """Propagate a mean through linear Gaussian transformation.""" return linop.matmul(mean) + dist.mean()[..., tf.newaxis]
def _propagate_mean(mean, linop, dist): """Propagate a mean through linear Gaussian transformation.""" return linop.matmul(mean) + dist.mean()[..., tf.newaxis]
[ "Propagate", "a", "mean", "through", "linear", "Gaussian", "transformation", "." ]
tensorflow/probability
python
https://github.com/tensorflow/probability/blob/e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5/tensorflow_probability/python/distributions/linear_gaussian_ssm.py#L1724-L1726
[ "def", "_propagate_mean", "(", "mean", ",", "linop", ",", "dist", ")", ":", "return", "linop", ".", "matmul", "(", "mean", ")", "+", "dist", ".", "mean", "(", ")", "[", "...", ",", "tf", ".", "newaxis", "]" ]
e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5
test
_propagate_cov
Propagate covariance through linear Gaussian transformation.
tensorflow_probability/python/distributions/linear_gaussian_ssm.py
def _propagate_cov(cov, linop, dist): """Propagate covariance through linear Gaussian transformation.""" # For linop A and input cov P, returns `A P A' + dist.cov()` return linop.matmul(linop.matmul(cov), adjoint_arg=True) + dist.covariance()
def _propagate_cov(cov, linop, dist): """Propagate covariance through linear Gaussian transformation.""" # For linop A and input cov P, returns `A P A' + dist.cov()` return linop.matmul(linop.matmul(cov), adjoint_arg=True) + dist.covariance()
[ "Propagate", "covariance", "through", "linear", "Gaussian", "transformation", "." ]
tensorflow/probability
python
https://github.com/tensorflow/probability/blob/e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5/tensorflow_probability/python/distributions/linear_gaussian_ssm.py#L1729-L1732
[ "def", "_propagate_cov", "(", "cov", ",", "linop", ",", "dist", ")", ":", "# For linop A and input cov P, returns `A P A' + dist.cov()`", "return", "linop", ".", "matmul", "(", "linop", ".", "matmul", "(", "cov", ")", ",", "adjoint_arg", "=", "True", ")", "+", ...
e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5
test
LinearGaussianStateSpaceModel.backward_smoothing_pass
Run the backward pass in Kalman smoother. The backward smoothing is using Rauch, Tung and Striebel smoother as as discussed in section 18.3.2 of Kevin P. Murphy, 2012, Machine Learning: A Probabilistic Perspective, The MIT Press. The inputs are returned by `forward_filter` function. Args: fi...
tensorflow_probability/python/distributions/linear_gaussian_ssm.py
def backward_smoothing_pass(self, filtered_means, filtered_covs, predicted_means, predicted_covs): """Run the backward pass in Kalman smoother. The backward smoothing is using Rauch, Tung and...
def backward_smoothing_pass(self, filtered_means, filtered_covs, predicted_means, predicted_covs): """Run the backward pass in Kalman smoother. The backward smoothing is using Rauch, Tung and...
[ "Run", "the", "backward", "pass", "in", "Kalman", "smoother", "." ]
tensorflow/probability
python
https://github.com/tensorflow/probability/blob/e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5/tensorflow_probability/python/distributions/linear_gaussian_ssm.py#L454-L541
[ "def", "backward_smoothing_pass", "(", "self", ",", "filtered_means", ",", "filtered_covs", ",", "predicted_means", ",", "predicted_covs", ")", ":", "with", "tf", ".", "name_scope", "(", "\"backward_pass\"", ")", ":", "filtered_means", "=", "tf", ".", "convert_to_...
e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5
test
LinearGaussianStateSpaceModel._joint_sample_n
Draw a joint sample from the prior over latents and observations.
tensorflow_probability/python/distributions/linear_gaussian_ssm.py
def _joint_sample_n(self, n, seed=None): """Draw a joint sample from the prior over latents and observations.""" with tf.name_scope("sample_n_joint"): stream = seed_stream.SeedStream( seed, salt="LinearGaussianStateSpaceModel_sample_n_joint") sample_and_batch_shape = distribution_util.pr...
def _joint_sample_n(self, n, seed=None): """Draw a joint sample from the prior over latents and observations.""" with tf.name_scope("sample_n_joint"): stream = seed_stream.SeedStream( seed, salt="LinearGaussianStateSpaceModel_sample_n_joint") sample_and_batch_shape = distribution_util.pr...
[ "Draw", "a", "joint", "sample", "from", "the", "prior", "over", "latents", "and", "observations", "." ]
tensorflow/probability
python
https://github.com/tensorflow/probability/blob/e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5/tensorflow_probability/python/distributions/linear_gaussian_ssm.py#L590-L665
[ "def", "_joint_sample_n", "(", "self", ",", "n", ",", "seed", "=", "None", ")", ":", "with", "tf", ".", "name_scope", "(", "\"sample_n_joint\"", ")", ":", "stream", "=", "seed_stream", ".", "SeedStream", "(", "seed", ",", "salt", "=", "\"LinearGaussianStat...
e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5
test
LinearGaussianStateSpaceModel.forward_filter
Run a Kalman filter over a provided sequence of outputs. Note that the returned values `filtered_means`, `predicted_means`, and `observation_means` depend on the observed time series `x`, while the corresponding covariances are independent of the observed series; i.e., they depend only on the model its...
tensorflow_probability/python/distributions/linear_gaussian_ssm.py
def forward_filter(self, x, mask=None): """Run a Kalman filter over a provided sequence of outputs. Note that the returned values `filtered_means`, `predicted_means`, and `observation_means` depend on the observed time series `x`, while the corresponding covariances are independent of the observed seri...
def forward_filter(self, x, mask=None): """Run a Kalman filter over a provided sequence of outputs. Note that the returned values `filtered_means`, `predicted_means`, and `observation_means` depend on the observed time series `x`, while the corresponding covariances are independent of the observed seri...
[ "Run", "a", "Kalman", "filter", "over", "a", "provided", "sequence", "of", "outputs", "." ]
tensorflow/probability
python
https://github.com/tensorflow/probability/blob/e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5/tensorflow_probability/python/distributions/linear_gaussian_ssm.py#L696-L912
[ "def", "forward_filter", "(", "self", ",", "x", ",", "mask", "=", "None", ")", ":", "with", "tf", ".", "name_scope", "(", "\"forward_filter\"", ")", ":", "x", "=", "tf", ".", "convert_to_tensor", "(", "value", "=", "x", ",", "name", "=", "\"x\"", ")"...
e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5
test
LinearGaussianStateSpaceModel.posterior_marginals
Run a Kalman smoother to return posterior mean and cov. Note that the returned values `smoothed_means` depend on the observed time series `x`, while the `smoothed_covs` are independent of the observed series; i.e., they depend only on the model itself. This means that the mean values have shape `concat...
tensorflow_probability/python/distributions/linear_gaussian_ssm.py
def posterior_marginals(self, x, mask=None): """Run a Kalman smoother to return posterior mean and cov. Note that the returned values `smoothed_means` depend on the observed time series `x`, while the `smoothed_covs` are independent of the observed series; i.e., they depend only on the model itself. ...
def posterior_marginals(self, x, mask=None): """Run a Kalman smoother to return posterior mean and cov. Note that the returned values `smoothed_means` depend on the observed time series `x`, while the `smoothed_covs` are independent of the observed series; i.e., they depend only on the model itself. ...
[ "Run", "a", "Kalman", "smoother", "to", "return", "posterior", "mean", "and", "cov", "." ]
tensorflow/probability
python
https://github.com/tensorflow/probability/blob/e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5/tensorflow_probability/python/distributions/linear_gaussian_ssm.py#L914-L975
[ "def", "posterior_marginals", "(", "self", ",", "x", ",", "mask", "=", "None", ")", ":", "with", "tf", ".", "name_scope", "(", "\"smooth\"", ")", ":", "x", "=", "tf", ".", "convert_to_tensor", "(", "value", "=", "x", ",", "name", "=", "\"x\"", ")", ...
e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5
test
LinearGaussianStateSpaceModel._joint_mean
Compute prior means for all variables via dynamic programming. Returns: latent_means: Prior means of latent states `z_t`, as a `Tensor` of shape `batch_shape + [num_timesteps, latent_size]` observation_means: Prior covariance matrices of observations `x_t`, as a `Tensor` of shape `batch...
tensorflow_probability/python/distributions/linear_gaussian_ssm.py
def _joint_mean(self): """Compute prior means for all variables via dynamic programming. Returns: latent_means: Prior means of latent states `z_t`, as a `Tensor` of shape `batch_shape + [num_timesteps, latent_size]` observation_means: Prior covariance matrices of observations `x_t`,...
def _joint_mean(self): """Compute prior means for all variables via dynamic programming. Returns: latent_means: Prior means of latent states `z_t`, as a `Tensor` of shape `batch_shape + [num_timesteps, latent_size]` observation_means: Prior covariance matrices of observations `x_t`,...
[ "Compute", "prior", "means", "for", "all", "variables", "via", "dynamic", "programming", "." ]
tensorflow/probability
python
https://github.com/tensorflow/probability/blob/e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5/tensorflow_probability/python/distributions/linear_gaussian_ssm.py#L981-L1038
[ "def", "_joint_mean", "(", "self", ")", ":", "with", "tf", ".", "name_scope", "(", "\"mean_joint\"", ")", ":", "# The initial timestep is a special case, since we sample the", "# latent state from the prior rather than the transition model.", "with", "tf", ".", "control_depende...
e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5
test
LinearGaussianStateSpaceModel._joint_covariances
Compute prior covariances for all variables via dynamic programming. Returns: latent_covs: Prior covariance matrices of latent states `z_t`, as a `Tensor` of shape `batch_shape + [num_timesteps, latent_size, latent_size]` observation_covs: Prior covariance matrices of observations ...
tensorflow_probability/python/distributions/linear_gaussian_ssm.py
def _joint_covariances(self): """Compute prior covariances for all variables via dynamic programming. Returns: latent_covs: Prior covariance matrices of latent states `z_t`, as a `Tensor` of shape `batch_shape + [num_timesteps, latent_size, latent_size]` observation_covs: Prior cova...
def _joint_covariances(self): """Compute prior covariances for all variables via dynamic programming. Returns: latent_covs: Prior covariance matrices of latent states `z_t`, as a `Tensor` of shape `batch_shape + [num_timesteps, latent_size, latent_size]` observation_covs: Prior cova...
[ "Compute", "prior", "covariances", "for", "all", "variables", "via", "dynamic", "programming", "." ]
tensorflow/probability
python
https://github.com/tensorflow/probability/blob/e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5/tensorflow_probability/python/distributions/linear_gaussian_ssm.py#L1040-L1091
[ "def", "_joint_covariances", "(", "self", ")", ":", "with", "tf", ".", "name_scope", "(", "\"covariance_joint\"", ")", ":", "with", "tf", ".", "control_dependencies", "(", "self", ".", "runtime_assertions", ")", ":", "initial_latent_cov", "=", "_broadcast_to_shape...
e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5
test
LinearGaussianStateSpaceModel.latents_to_observations
Push latent means and covariances forward through the observation model. Args: latent_means: float `Tensor` of shape `[..., num_timesteps, latent_size]` latent_covs: float `Tensor` of shape `[..., num_timesteps, latent_size, latent_size]`. Returns: observation_means: float `Tensor` o...
tensorflow_probability/python/distributions/linear_gaussian_ssm.py
def latents_to_observations(self, latent_means, latent_covs): """Push latent means and covariances forward through the observation model. Args: latent_means: float `Tensor` of shape `[..., num_timesteps, latent_size]` latent_covs: float `Tensor` of shape `[..., num_timesteps, latent_size, l...
def latents_to_observations(self, latent_means, latent_covs): """Push latent means and covariances forward through the observation model. Args: latent_means: float `Tensor` of shape `[..., num_timesteps, latent_size]` latent_covs: float `Tensor` of shape `[..., num_timesteps, latent_size, l...
[ "Push", "latent", "means", "and", "covariances", "forward", "through", "the", "observation", "model", "." ]
tensorflow/probability
python
https://github.com/tensorflow/probability/blob/e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5/tensorflow_probability/python/distributions/linear_gaussian_ssm.py#L1097-L1145
[ "def", "latents_to_observations", "(", "self", ",", "latent_means", ",", "latent_covs", ")", ":", "with", "tf", ".", "name_scope", "(", "\"latents_to_observations\"", ")", ":", "pushforward_latents_step", "=", "build_pushforward_latents_step", "(", "self", ".", "get_o...
e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5
test
_bessel_ive
Computes I_v(z)*exp(-abs(z)) using a recurrence relation, where z > 0.
tensorflow_probability/python/distributions/von_mises_fisher.py
def _bessel_ive(v, z, cache=None): """Computes I_v(z)*exp(-abs(z)) using a recurrence relation, where z > 0.""" # TODO(b/67497980): Switch to a more numerically faithful implementation. z = tf.convert_to_tensor(value=z) wrap = lambda result: tf.debugging.check_numerics(result, 'besseli{}'.format(v ...
def _bessel_ive(v, z, cache=None): """Computes I_v(z)*exp(-abs(z)) using a recurrence relation, where z > 0.""" # TODO(b/67497980): Switch to a more numerically faithful implementation. z = tf.convert_to_tensor(value=z) wrap = lambda result: tf.debugging.check_numerics(result, 'besseli{}'.format(v ...
[ "Computes", "I_v", "(", "z", ")", "*", "exp", "(", "-", "abs", "(", "z", "))", "using", "a", "recurrence", "relation", "where", "z", ">", "0", "." ]
tensorflow/probability
python
https://github.com/tensorflow/probability/blob/e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5/tensorflow_probability/python/distributions/von_mises_fisher.py#L36-L73
[ "def", "_bessel_ive", "(", "v", ",", "z", ",", "cache", "=", "None", ")", ":", "# TODO(b/67497980): Switch to a more numerically faithful implementation.", "z", "=", "tf", ".", "convert_to_tensor", "(", "value", "=", "z", ")", "wrap", "=", "lambda", "result", ":...
e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5
test
VonMisesFisher._log_normalization
Computes the log-normalizer of the distribution.
tensorflow_probability/python/distributions/von_mises_fisher.py
def _log_normalization(self): """Computes the log-normalizer of the distribution.""" event_dim = tf.compat.dimension_value(self.event_shape[0]) if event_dim is None: raise ValueError('vMF _log_normalizer currently only supports ' 'statically known event shape') safe_conc = t...
def _log_normalization(self): """Computes the log-normalizer of the distribution.""" event_dim = tf.compat.dimension_value(self.event_shape[0]) if event_dim is None: raise ValueError('vMF _log_normalizer currently only supports ' 'statically known event shape') safe_conc = t...
[ "Computes", "the", "log", "-", "normalizer", "of", "the", "distribution", "." ]
tensorflow/probability
python
https://github.com/tensorflow/probability/blob/e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5/tensorflow_probability/python/distributions/von_mises_fisher.py#L262-L280
[ "def", "_log_normalization", "(", "self", ")", ":", "event_dim", "=", "tf", ".", "compat", ".", "dimension_value", "(", "self", ".", "event_shape", "[", "0", "]", ")", "if", "event_dim", "is", "None", ":", "raise", "ValueError", "(", "'vMF _log_normalizer cu...
e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5
test
VonMisesFisher._maybe_assert_valid_sample
Check counts for proper shape, values, then return tensor version.
tensorflow_probability/python/distributions/von_mises_fisher.py
def _maybe_assert_valid_sample(self, samples): """Check counts for proper shape, values, then return tensor version.""" if not self.validate_args: return samples with tf.control_dependencies([ assert_util.assert_near( 1., tf.linalg.norm(tensor=samples, axis=-1), ...
def _maybe_assert_valid_sample(self, samples): """Check counts for proper shape, values, then return tensor version.""" if not self.validate_args: return samples with tf.control_dependencies([ assert_util.assert_near( 1., tf.linalg.norm(tensor=samples, axis=-1), ...
[ "Check", "counts", "for", "proper", "shape", "values", "then", "return", "tensor", "version", "." ]
tensorflow/probability
python
https://github.com/tensorflow/probability/blob/e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5/tensorflow_probability/python/distributions/von_mises_fisher.py#L285-L300
[ "def", "_maybe_assert_valid_sample", "(", "self", ",", "samples", ")", ":", "if", "not", "self", ".", "validate_args", ":", "return", "samples", "with", "tf", ".", "control_dependencies", "(", "[", "assert_util", ".", "assert_near", "(", "1.", ",", "tf", "."...
e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5
test
VonMisesFisher._mode
The mode of the von Mises-Fisher distribution is the mean direction.
tensorflow_probability/python/distributions/von_mises_fisher.py
def _mode(self): """The mode of the von Mises-Fisher distribution is the mean direction.""" return (self.mean_direction + tf.zeros_like(self.concentration)[..., tf.newaxis])
def _mode(self): """The mode of the von Mises-Fisher distribution is the mean direction.""" return (self.mean_direction + tf.zeros_like(self.concentration)[..., tf.newaxis])
[ "The", "mode", "of", "the", "von", "Mises", "-", "Fisher", "distribution", "is", "the", "mean", "direction", "." ]
tensorflow/probability
python
https://github.com/tensorflow/probability/blob/e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5/tensorflow_probability/python/distributions/von_mises_fisher.py#L302-L305
[ "def", "_mode", "(", "self", ")", ":", "return", "(", "self", ".", "mean_direction", "+", "tf", ".", "zeros_like", "(", "self", ".", "concentration", ")", "[", "...", ",", "tf", ".", "newaxis", "]", ")" ]
e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5
test
VonMisesFisher._rotate
Applies a Householder rotation to `samples`.
tensorflow_probability/python/distributions/von_mises_fisher.py
def _rotate(self, samples): """Applies a Householder rotation to `samples`.""" event_dim = ( tf.compat.dimension_value(self.event_shape[0]) or self._event_shape_tensor()[0]) basis = tf.concat([[1.], tf.zeros([event_dim - 1], dtype=self.dtype)], axis=0), u = tf.nn.l2...
def _rotate(self, samples): """Applies a Householder rotation to `samples`.""" event_dim = ( tf.compat.dimension_value(self.event_shape[0]) or self._event_shape_tensor()[0]) basis = tf.concat([[1.], tf.zeros([event_dim - 1], dtype=self.dtype)], axis=0), u = tf.nn.l2...
[ "Applies", "a", "Householder", "rotation", "to", "samples", "." ]
tensorflow/probability
python
https://github.com/tensorflow/probability/blob/e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5/tensorflow_probability/python/distributions/von_mises_fisher.py#L347-L356
[ "def", "_rotate", "(", "self", ",", "samples", ")", ":", "event_dim", "=", "(", "tf", ".", "compat", ".", "dimension_value", "(", "self", ".", "event_shape", "[", "0", "]", ")", "or", "self", ".", "_event_shape_tensor", "(", ")", "[", "0", "]", ")", ...
e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5
test
VonMisesFisher._sample_3d
Specialized inversion sampler for 3D.
tensorflow_probability/python/distributions/von_mises_fisher.py
def _sample_3d(self, n, seed=None): """Specialized inversion sampler for 3D.""" seed = seed_stream.SeedStream(seed, salt='von_mises_fisher_3d') u_shape = tf.concat([[n], self._batch_shape_tensor()], axis=0) z = tf.random.uniform(u_shape, seed=seed(), dtype=self.dtype) # TODO(bjp): Higher-order odd d...
def _sample_3d(self, n, seed=None): """Specialized inversion sampler for 3D.""" seed = seed_stream.SeedStream(seed, salt='von_mises_fisher_3d') u_shape = tf.concat([[n], self._batch_shape_tensor()], axis=0) z = tf.random.uniform(u_shape, seed=seed(), dtype=self.dtype) # TODO(bjp): Higher-order odd d...
[ "Specialized", "inversion", "sampler", "for", "3D", "." ]
tensorflow/probability
python
https://github.com/tensorflow/probability/blob/e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5/tensorflow_probability/python/distributions/von_mises_fisher.py#L358-L385
[ "def", "_sample_3d", "(", "self", ",", "n", ",", "seed", "=", "None", ")", ":", "seed", "=", "seed_stream", ".", "SeedStream", "(", "seed", ",", "salt", "=", "'von_mises_fisher_3d'", ")", "u_shape", "=", "tf", ".", "concat", "(", "[", "[", "n", "]", ...
e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5
test
_copy_fn
Create a deep copy of fn. Args: fn: a callable Returns: A `FunctionType`: a deep copy of fn. Raises: TypeError: if `fn` is not a callable.
tensorflow_probability/python/distributions/distribution.py
def _copy_fn(fn): """Create a deep copy of fn. Args: fn: a callable Returns: A `FunctionType`: a deep copy of fn. Raises: TypeError: if `fn` is not a callable. """ if not callable(fn): raise TypeError("fn is not callable: {}".format(fn)) # The blessed way to copy a function. copy.deepco...
def _copy_fn(fn): """Create a deep copy of fn. Args: fn: a callable Returns: A `FunctionType`: a deep copy of fn. Raises: TypeError: if `fn` is not a callable. """ if not callable(fn): raise TypeError("fn is not callable: {}".format(fn)) # The blessed way to copy a function. copy.deepco...
[ "Create", "a", "deep", "copy", "of", "fn", "." ]
tensorflow/probability
python
https://github.com/tensorflow/probability/blob/e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5/tensorflow_probability/python/distributions/distribution.py#L75-L104
[ "def", "_copy_fn", "(", "fn", ")", ":", "if", "not", "callable", "(", "fn", ")", ":", "raise", "TypeError", "(", "\"fn is not callable: {}\"", ".", "format", "(", "fn", ")", ")", "# The blessed way to copy a function. copy.deepcopy fails to create a", "# non-reference...
e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5
test
_update_docstring
Update old_str by inserting append_str just before the "Args:" section.
tensorflow_probability/python/distributions/distribution.py
def _update_docstring(old_str, append_str): """Update old_str by inserting append_str just before the "Args:" section.""" old_str = old_str or "" old_str_lines = old_str.split("\n") # Step 0: Prepend spaces to all lines of append_str. This is # necessary for correct markdown generation. append_str = "\n".j...
def _update_docstring(old_str, append_str): """Update old_str by inserting append_str just before the "Args:" section.""" old_str = old_str or "" old_str_lines = old_str.split("\n") # Step 0: Prepend spaces to all lines of append_str. This is # necessary for correct markdown generation. append_str = "\n".j...
[ "Update", "old_str", "by", "inserting", "append_str", "just", "before", "the", "Args", ":", "section", "." ]
tensorflow/probability
python
https://github.com/tensorflow/probability/blob/e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5/tensorflow_probability/python/distributions/distribution.py#L107-L126
[ "def", "_update_docstring", "(", "old_str", ",", "append_str", ")", ":", "old_str", "=", "old_str", "or", "\"\"", "old_str_lines", "=", "old_str", ".", "split", "(", "\"\\n\"", ")", "# Step 0: Prepend spaces to all lines of append_str. This is", "# necessary for correct m...
e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5
test
_convert_to_tensor
Converts the given `value` to a (structure of) `Tensor`. This function converts Python objects of various types to a (structure of) `Tensor` objects. It accepts `Tensor` objects, numpy arrays, Python lists, and Python scalars. For example: Args: value: An object whose structure matches that of `dtype ` an...
tensorflow_probability/python/distributions/distribution.py
def _convert_to_tensor(value, dtype=None, dtype_hint=None, name=None): """Converts the given `value` to a (structure of) `Tensor`. This function converts Python objects of various types to a (structure of) `Tensor` objects. It accepts `Tensor` objects, numpy arrays, Python lists, and Python scalars. For exampl...
def _convert_to_tensor(value, dtype=None, dtype_hint=None, name=None): """Converts the given `value` to a (structure of) `Tensor`. This function converts Python objects of various types to a (structure of) `Tensor` objects. It accepts `Tensor` objects, numpy arrays, Python lists, and Python scalars. For exampl...
[ "Converts", "the", "given", "value", "to", "a", "(", "structure", "of", ")", "Tensor", "." ]
tensorflow/probability
python
https://github.com/tensorflow/probability/blob/e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5/tensorflow_probability/python/distributions/distribution.py#L129-L170
[ "def", "_convert_to_tensor", "(", "value", ",", "dtype", "=", "None", ",", "dtype_hint", "=", "None", ",", "name", "=", "None", ")", ":", "if", "(", "tf", ".", "nest", ".", "is_nested", "(", "dtype", ")", "or", "tf", ".", "nest", ".", "is_nested", ...
e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5
test
_remove_dict_keys_with_value
Removes `dict` keys which have have `self` as value.
tensorflow_probability/python/distributions/distribution.py
def _remove_dict_keys_with_value(dict_, val): """Removes `dict` keys which have have `self` as value.""" return {k: v for k, v in dict_.items() if v is not val}
def _remove_dict_keys_with_value(dict_, val): """Removes `dict` keys which have have `self` as value.""" return {k: v for k, v in dict_.items() if v is not val}
[ "Removes", "dict", "keys", "which", "have", "have", "self", "as", "value", "." ]
tensorflow/probability
python
https://github.com/tensorflow/probability/blob/e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5/tensorflow_probability/python/distributions/distribution.py#L173-L175
[ "def", "_remove_dict_keys_with_value", "(", "dict_", ",", "val", ")", ":", "return", "{", "k", ":", "v", "for", "k", ",", "v", "in", "dict_", ".", "items", "(", ")", "if", "v", "is", "not", "val", "}" ]
e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5
test
_recursively_replace_dict_for_pretty_dict
Recursively replace `dict`s with `_PrettyDict`.
tensorflow_probability/python/distributions/distribution.py
def _recursively_replace_dict_for_pretty_dict(x): """Recursively replace `dict`s with `_PrettyDict`.""" # We use "PrettyDict" because collections.OrderedDict repr/str has the word # "OrderedDict" in it. We only want to print "OrderedDict" if in fact the # input really is an OrderedDict. if isinstance(x, dict)...
def _recursively_replace_dict_for_pretty_dict(x): """Recursively replace `dict`s with `_PrettyDict`.""" # We use "PrettyDict" because collections.OrderedDict repr/str has the word # "OrderedDict" in it. We only want to print "OrderedDict" if in fact the # input really is an OrderedDict. if isinstance(x, dict)...
[ "Recursively", "replace", "dict", "s", "with", "_PrettyDict", "." ]
tensorflow/probability
python
https://github.com/tensorflow/probability/blob/e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5/tensorflow_probability/python/distributions/distribution.py#L1392-L1411
[ "def", "_recursively_replace_dict_for_pretty_dict", "(", "x", ")", ":", "# We use \"PrettyDict\" because collections.OrderedDict repr/str has the word", "# \"OrderedDict\" in it. We only want to print \"OrderedDict\" if in fact the", "# input really is an OrderedDict.", "if", "isinstance", "("...
e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5
test
expectation
Computes the Monte-Carlo approximation of `E_p[f(X)]`. This function computes the Monte-Carlo approximation of an expectation, i.e., ```none E_p[f(X)] approx= m**-1 sum_i^m f(x_j), x_j ~iid p(X) ``` where: - `x_j = samples[j, ...]`, - `log(p(samples)) = log_prob(samples)` and - `m = prod(shape(samp...
tensorflow_probability/python/monte_carlo/expectation.py
def expectation(f, samples, log_prob=None, use_reparametrization=True, axis=0, keep_dims=False, name=None): """Computes the Monte-Carlo approximation of `E_p[f(X)]`. This function computes the Monte-Carlo approximation of an expectation, i.e., ```none E_p[f(X)] approx= m**-1 sum_i^m f(x_j), x...
def expectation(f, samples, log_prob=None, use_reparametrization=True, axis=0, keep_dims=False, name=None): """Computes the Monte-Carlo approximation of `E_p[f(X)]`. This function computes the Monte-Carlo approximation of an expectation, i.e., ```none E_p[f(X)] approx= m**-1 sum_i^m f(x_j), x...
[ "Computes", "the", "Monte", "-", "Carlo", "approximation", "of", "E_p", "[", "f", "(", "X", ")", "]", "." ]
tensorflow/probability
python
https://github.com/tensorflow/probability/blob/e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5/tensorflow_probability/python/monte_carlo/expectation.py#L29-L192
[ "def", "expectation", "(", "f", ",", "samples", ",", "log_prob", "=", "None", ",", "use_reparametrization", "=", "True", ",", "axis", "=", "0", ",", "keep_dims", "=", "False", ",", "name", "=", "None", ")", ":", "with", "tf", ".", "compat", ".", "v1"...
e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5
test
_get_samples
Check args and return samples.
tensorflow_probability/python/monte_carlo/expectation.py
def _get_samples(dist, z, n, seed): """Check args and return samples.""" with tf.compat.v1.name_scope('get_samples', values=[z, n]): if (n is None) == (z is None): raise ValueError( 'Must specify exactly one of arguments "n" and "z". Found: ' 'n = %s, z = %s' % (n, z)) if n is not...
def _get_samples(dist, z, n, seed): """Check args and return samples.""" with tf.compat.v1.name_scope('get_samples', values=[z, n]): if (n is None) == (z is None): raise ValueError( 'Must specify exactly one of arguments "n" and "z". Found: ' 'n = %s, z = %s' % (n, z)) if n is not...
[ "Check", "args", "and", "return", "samples", "." ]
tensorflow/probability
python
https://github.com/tensorflow/probability/blob/e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5/tensorflow_probability/python/monte_carlo/expectation.py#L205-L215
[ "def", "_get_samples", "(", "dist", ",", "z", ",", "n", ",", "seed", ")", ":", "with", "tf", ".", "compat", ".", "v1", ".", "name_scope", "(", "'get_samples'", ",", "values", "=", "[", "z", ",", "n", "]", ")", ":", "if", "(", "n", "is", "None",...
e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5
test
is_namedtuple_like
Helper which returns `True` if input is `collections.namedtuple`-like.
tensorflow_probability/python/mcmc/internal/util.py
def is_namedtuple_like(x): """Helper which returns `True` if input is `collections.namedtuple`-like.""" try: for fn in x._fields: _ = getattr(x, fn) return True except AttributeError: return False
def is_namedtuple_like(x): """Helper which returns `True` if input is `collections.namedtuple`-like.""" try: for fn in x._fields: _ = getattr(x, fn) return True except AttributeError: return False
[ "Helper", "which", "returns", "True", "if", "input", "is", "collections", ".", "namedtuple", "-", "like", "." ]
tensorflow/probability
python
https://github.com/tensorflow/probability/blob/e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5/tensorflow_probability/python/mcmc/internal/util.py#L56-L63
[ "def", "is_namedtuple_like", "(", "x", ")", ":", "try", ":", "for", "fn", "in", "x", ".", "_fields", ":", "_", "=", "getattr", "(", "x", ",", "fn", ")", "return", "True", "except", "AttributeError", ":", "return", "False" ]
e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5
test
make_name
Helper which makes a `str` name; useful for tf.compat.v1.name_scope.
tensorflow_probability/python/mcmc/internal/util.py
def make_name(super_name, default_super_name, sub_name): """Helper which makes a `str` name; useful for tf.compat.v1.name_scope.""" name = super_name if super_name is not None else default_super_name if sub_name is not None: name += '_' + sub_name return name
def make_name(super_name, default_super_name, sub_name): """Helper which makes a `str` name; useful for tf.compat.v1.name_scope.""" name = super_name if super_name is not None else default_super_name if sub_name is not None: name += '_' + sub_name return name
[ "Helper", "which", "makes", "a", "str", "name", ";", "useful", "for", "tf", ".", "compat", ".", "v1", ".", "name_scope", "." ]
tensorflow/probability
python
https://github.com/tensorflow/probability/blob/e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5/tensorflow_probability/python/mcmc/internal/util.py#L66-L71
[ "def", "make_name", "(", "super_name", ",", "default_super_name", ",", "sub_name", ")", ":", "name", "=", "super_name", "if", "super_name", "is", "not", "None", "else", "default_super_name", "if", "sub_name", "is", "not", "None", ":", "name", "+=", "'_'", "+...
e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5
test
_choose_base_case
Helper to `choose` which expand_dims `is_accepted` and applies tf.where.
tensorflow_probability/python/mcmc/internal/util.py
def _choose_base_case(is_accepted, accepted, rejected, name=None): """Helper to `choose` which expand_dims `is_accepted` and applies tf.where.""" def _expand_is_accepted_like(x): """Helper to expand `is_accepted` like the shape of some input arg....
def _choose_base_case(is_accepted, accepted, rejected, name=None): """Helper to `choose` which expand_dims `is_accepted` and applies tf.where.""" def _expand_is_accepted_like(x): """Helper to expand `is_accepted` like the shape of some input arg....
[ "Helper", "to", "choose", "which", "expand_dims", "is_accepted", "and", "applies", "tf", ".", "where", "." ]
tensorflow/probability
python
https://github.com/tensorflow/probability/blob/e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5/tensorflow_probability/python/mcmc/internal/util.py#L74-L111
[ "def", "_choose_base_case", "(", "is_accepted", ",", "accepted", ",", "rejected", ",", "name", "=", "None", ")", ":", "def", "_expand_is_accepted_like", "(", "x", ")", ":", "\"\"\"Helper to expand `is_accepted` like the shape of some input arg.\"\"\"", "with", "tf", "."...
e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5
test
choose
Helper which expand_dims `is_accepted` then applies tf.where.
tensorflow_probability/python/mcmc/internal/util.py
def choose(is_accepted, accepted, rejected, name=None): """Helper which expand_dims `is_accepted` then applies tf.where.""" if not is_namedtuple_like(accepted): return _choose_base_case(is_accepted, accepted, rejected, name=name) if not isinstance(accepted, type(rejected)): raise TypeError('Type of `accep...
def choose(is_accepted, accepted, rejected, name=None): """Helper which expand_dims `is_accepted` then applies tf.where.""" if not is_namedtuple_like(accepted): return _choose_base_case(is_accepted, accepted, rejected, name=name) if not isinstance(accepted, type(rejected)): raise TypeError('Type of `accep...
[ "Helper", "which", "expand_dims", "is_accepted", "then", "applies", "tf", ".", "where", "." ]
tensorflow/probability
python
https://github.com/tensorflow/probability/blob/e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5/tensorflow_probability/python/mcmc/internal/util.py#L114-L129
[ "def", "choose", "(", "is_accepted", ",", "accepted", ",", "rejected", ",", "name", "=", "None", ")", ":", "if", "not", "is_namedtuple_like", "(", "accepted", ")", ":", "return", "_choose_base_case", "(", "is_accepted", ",", "accepted", ",", "rejected", ",",...
e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5
test
safe_sum
Elementwise adds list members, replacing non-finite results with alt_value. Typically the `alt_value` is chosen so the `MetropolisHastings` `TransitionKernel` always rejects the proposal. Args: x: Python `list` of `Tensors` to elementwise add. alt_value: Python scalar used to replace any elementwise sum...
tensorflow_probability/python/mcmc/internal/util.py
def safe_sum(x, alt_value=-np.inf, name=None): """Elementwise adds list members, replacing non-finite results with alt_value. Typically the `alt_value` is chosen so the `MetropolisHastings` `TransitionKernel` always rejects the proposal. Args: x: Python `list` of `Tensors` to elementwise add. alt_valu...
def safe_sum(x, alt_value=-np.inf, name=None): """Elementwise adds list members, replacing non-finite results with alt_value. Typically the `alt_value` is chosen so the `MetropolisHastings` `TransitionKernel` always rejects the proposal. Args: x: Python `list` of `Tensors` to elementwise add. alt_valu...
[ "Elementwise", "adds", "list", "members", "replacing", "non", "-", "finite", "results", "with", "alt_value", "." ]
tensorflow/probability
python
https://github.com/tensorflow/probability/blob/e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5/tensorflow_probability/python/mcmc/internal/util.py#L132-L165
[ "def", "safe_sum", "(", "x", ",", "alt_value", "=", "-", "np", ".", "inf", ",", "name", "=", "None", ")", ":", "with", "tf", ".", "compat", ".", "v1", ".", "name_scope", "(", "name", ",", "'safe_sum'", ",", "[", "x", ",", "alt_value", "]", ")", ...
e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5