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 | request | same as requests/requests/api.py request(...) | searx/poolrequests.py | def request(method, url, **kwargs):
"""same as requests/requests/api.py request(...)"""
time_before_request = time()
# session start
session = SessionSinglePool()
# proxies
kwargs['proxies'] = settings['outgoing'].get('proxies') or None
# timeout
if 'timeout' in kwargs:
timeou... | def request(method, url, **kwargs):
"""same as requests/requests/api.py request(...)"""
time_before_request = time()
# session start
session = SessionSinglePool()
# proxies
kwargs['proxies'] = settings['outgoing'].get('proxies') or None
# timeout
if 'timeout' in kwargs:
timeou... | [
"same",
"as",
"requests",
"/",
"requests",
"/",
"api",
".",
"py",
"request",
"(",
"...",
")"
] | asciimoo/searx | python | https://github.com/asciimoo/searx/blob/a84caa22cf947e973c10aa968d35fb2bdda6d048/searx/poolrequests.py#L90-L128 | [
"def",
"request",
"(",
"method",
",",
"url",
",",
"*",
"*",
"kwargs",
")",
":",
"time_before_request",
"=",
"time",
"(",
")",
"# session start",
"session",
"=",
"SessionSinglePool",
"(",
")",
"# proxies",
"kwargs",
"[",
"'proxies'",
"]",
"=",
"settings",
"... | a84caa22cf947e973c10aa968d35fb2bdda6d048 |
test | get_current_theme_name | Returns theme name.
Checks in this order:
1. override
2. cookies
3. settings | searx/webapp.py | def get_current_theme_name(override=None):
"""Returns theme name.
Checks in this order:
1. override
2. cookies
3. settings"""
if override and (override in themes or override == '__common__'):
return override
theme_name = request.args.get('theme', request.preferences.get_value('them... | def get_current_theme_name(override=None):
"""Returns theme name.
Checks in this order:
1. override
2. cookies
3. settings"""
if override and (override in themes or override == '__common__'):
return override
theme_name = request.args.get('theme', request.preferences.get_value('them... | [
"Returns",
"theme",
"name",
"."
] | asciimoo/searx | python | https://github.com/asciimoo/searx/blob/a84caa22cf947e973c10aa968d35fb2bdda6d048/searx/webapp.py#L240-L253 | [
"def",
"get_current_theme_name",
"(",
"override",
"=",
"None",
")",
":",
"if",
"override",
"and",
"(",
"override",
"in",
"themes",
"or",
"override",
"==",
"'__common__'",
")",
":",
"return",
"override",
"theme_name",
"=",
"request",
".",
"args",
".",
"get",
... | a84caa22cf947e973c10aa968d35fb2bdda6d048 |
test | index | Render index page.
Supported outputs: html, json, csv, rss. | searx/webapp.py | def index():
"""Render index page.
Supported outputs: html, json, csv, rss.
"""
# output_format
output_format = request.form.get('format', 'html')
if output_format not in ['html', 'csv', 'json', 'rss']:
output_format = 'html'
# check if there is query
if request.form.get('q') ... | def index():
"""Render index page.
Supported outputs: html, json, csv, rss.
"""
# output_format
output_format = request.form.get('format', 'html')
if output_format not in ['html', 'csv', 'json', 'rss']:
output_format = 'html'
# check if there is query
if request.form.get('q') ... | [
"Render",
"index",
"page",
"."
] | asciimoo/searx | python | https://github.com/asciimoo/searx/blob/a84caa22cf947e973c10aa968d35fb2bdda6d048/searx/webapp.py#L470-L604 | [
"def",
"index",
"(",
")",
":",
"# output_format",
"output_format",
"=",
"request",
".",
"form",
".",
"get",
"(",
"'format'",
",",
"'html'",
")",
"if",
"output_format",
"not",
"in",
"[",
"'html'",
",",
"'csv'",
",",
"'json'",
",",
"'rss'",
"]",
":",
"ou... | a84caa22cf947e973c10aa968d35fb2bdda6d048 |
test | autocompleter | Return autocompleter results | searx/webapp.py | def autocompleter():
"""Return autocompleter results"""
# set blocked engines
disabled_engines = request.preferences.engines.get_disabled()
# parse query
if PY3:
raw_text_query = RawTextQuery(request.form.get('q', b''), disabled_engines)
else:
raw_text_query = RawTextQuery(requ... | def autocompleter():
"""Return autocompleter results"""
# set blocked engines
disabled_engines = request.preferences.engines.get_disabled()
# parse query
if PY3:
raw_text_query = RawTextQuery(request.form.get('q', b''), disabled_engines)
else:
raw_text_query = RawTextQuery(requ... | [
"Return",
"autocompleter",
"results"
] | asciimoo/searx | python | https://github.com/asciimoo/searx/blob/a84caa22cf947e973c10aa968d35fb2bdda6d048/searx/webapp.py#L616-L664 | [
"def",
"autocompleter",
"(",
")",
":",
"# set blocked engines",
"disabled_engines",
"=",
"request",
".",
"preferences",
".",
"engines",
".",
"get_disabled",
"(",
")",
"# parse query",
"if",
"PY3",
":",
"raw_text_query",
"=",
"RawTextQuery",
"(",
"request",
".",
... | a84caa22cf947e973c10aa968d35fb2bdda6d048 |
test | preferences | Render preferences page && save user preferences | searx/webapp.py | def preferences():
"""Render preferences page && save user preferences"""
# save preferences
if request.method == 'POST':
resp = make_response(redirect(urljoin(settings['server']['base_url'], url_for('index'))))
try:
request.preferences.parse_form(request.form)
except Va... | def preferences():
"""Render preferences page && save user preferences"""
# save preferences
if request.method == 'POST':
resp = make_response(redirect(urljoin(settings['server']['base_url'], url_for('index'))))
try:
request.preferences.parse_form(request.form)
except Va... | [
"Render",
"preferences",
"page",
"&&",
"save",
"user",
"preferences"
] | asciimoo/searx | python | https://github.com/asciimoo/searx/blob/a84caa22cf947e973c10aa968d35fb2bdda6d048/searx/webapp.py#L668-L725 | [
"def",
"preferences",
"(",
")",
":",
"# save preferences",
"if",
"request",
".",
"method",
"==",
"'POST'",
":",
"resp",
"=",
"make_response",
"(",
"redirect",
"(",
"urljoin",
"(",
"settings",
"[",
"'server'",
"]",
"[",
"'base_url'",
"]",
",",
"url_for",
"(... | a84caa22cf947e973c10aa968d35fb2bdda6d048 |
test | request | pre-request callback
params<dict>:
method : POST/GET
headers : {}
data : {} # if method == POST
url : ''
category: 'search category'
pageno : 1 # number of the requested page | searx/engines/duden.py | def request(query, params):
'''pre-request callback
params<dict>:
method : POST/GET
headers : {}
data : {} # if method == POST
url : ''
category: 'search category'
pageno : 1 # number of the requested page
'''
offset = (params['pageno'] - 1)
params['url'... | def request(query, params):
'''pre-request callback
params<dict>:
method : POST/GET
headers : {}
data : {} # if method == POST
url : ''
category: 'search category'
pageno : 1 # number of the requested page
'''
offset = (params['pageno'] - 1)
params['url'... | [
"pre",
"-",
"request",
"callback",
"params<dict",
">",
":",
"method",
":",
"POST",
"/",
"GET",
"headers",
":",
"{}",
"data",
":",
"{}",
"#",
"if",
"method",
"==",
"POST",
"url",
":",
"category",
":",
"search",
"category",
"pageno",
":",
"1",
"#",
"nu... | asciimoo/searx | python | https://github.com/asciimoo/searx/blob/a84caa22cf947e973c10aa968d35fb2bdda6d048/searx/engines/duden.py#L26-L39 | [
"def",
"request",
"(",
"query",
",",
"params",
")",
":",
"offset",
"=",
"(",
"params",
"[",
"'pageno'",
"]",
"-",
"1",
")",
"params",
"[",
"'url'",
"]",
"=",
"search_url",
".",
"format",
"(",
"offset",
"=",
"offset",
",",
"query",
"=",
"quote",
"("... | a84caa22cf947e973c10aa968d35fb2bdda6d048 |
test | response | post-response callback
resp: requests response object | searx/engines/duden.py | def response(resp):
'''post-response callback
resp: requests response object
'''
results = []
dom = html.fromstring(resp.text)
try:
number_of_results_string = re.sub('[^0-9]', '', dom.xpath(
'//a[@class="active" and contains(@href,"/suchen/dudenonline")]/span/text()')[0]
... | def response(resp):
'''post-response callback
resp: requests response object
'''
results = []
dom = html.fromstring(resp.text)
try:
number_of_results_string = re.sub('[^0-9]', '', dom.xpath(
'//a[@class="active" and contains(@href,"/suchen/dudenonline")]/span/text()')[0]
... | [
"post",
"-",
"response",
"callback",
"resp",
":",
"requests",
"response",
"object"
] | asciimoo/searx | python | https://github.com/asciimoo/searx/blob/a84caa22cf947e973c10aa968d35fb2bdda6d048/searx/engines/duden.py#L42-L76 | [
"def",
"response",
"(",
"resp",
")",
":",
"results",
"=",
"[",
"]",
"dom",
"=",
"html",
".",
"fromstring",
"(",
"resp",
".",
"text",
")",
"try",
":",
"number_of_results_string",
"=",
"re",
".",
"sub",
"(",
"'[^0-9]'",
",",
"''",
",",
"dom",
".",
"x... | a84caa22cf947e973c10aa968d35fb2bdda6d048 |
test | get_themes | Returns available themes list. | searx/utils.py | def get_themes(templates_path):
"""Returns available themes list."""
themes = os.listdir(templates_path)
if '__common__' in themes:
themes.remove('__common__')
return themes | def get_themes(templates_path):
"""Returns available themes list."""
themes = os.listdir(templates_path)
if '__common__' in themes:
themes.remove('__common__')
return themes | [
"Returns",
"available",
"themes",
"list",
"."
] | asciimoo/searx | python | https://github.com/asciimoo/searx/blob/a84caa22cf947e973c10aa968d35fb2bdda6d048/searx/utils.py#L190-L195 | [
"def",
"get_themes",
"(",
"templates_path",
")",
":",
"themes",
"=",
"os",
".",
"listdir",
"(",
"templates_path",
")",
"if",
"'__common__'",
"in",
"themes",
":",
"themes",
".",
"remove",
"(",
"'__common__'",
")",
"return",
"themes"
] | a84caa22cf947e973c10aa968d35fb2bdda6d048 |
test | searx_bang | check if the searchQuery contain a bang, and create fitting autocompleter results | searx/autocomplete.py | def searx_bang(full_query):
'''check if the searchQuery contain a bang, and create fitting autocompleter results'''
# check if there is a query which can be parsed
if len(full_query.getSearchQuery()) == 0:
return []
results = []
# check if current query stats with !bang
first_char = fu... | def searx_bang(full_query):
'''check if the searchQuery contain a bang, and create fitting autocompleter results'''
# check if there is a query which can be parsed
if len(full_query.getSearchQuery()) == 0:
return []
results = []
# check if current query stats with !bang
first_char = fu... | [
"check",
"if",
"the",
"searchQuery",
"contain",
"a",
"bang",
"and",
"create",
"fitting",
"autocompleter",
"results"
] | asciimoo/searx | python | https://github.com/asciimoo/searx/blob/a84caa22cf947e973c10aa968d35fb2bdda6d048/searx/autocomplete.py#L37-L110 | [
"def",
"searx_bang",
"(",
"full_query",
")",
":",
"# check if there is a query which can be parsed",
"if",
"len",
"(",
"full_query",
".",
"getSearchQuery",
"(",
")",
")",
"==",
"0",
":",
"return",
"[",
"]",
"results",
"=",
"[",
"]",
"# check if current query stats... | a84caa22cf947e973c10aa968d35fb2bdda6d048 |
test | response | remove first and last lines to get only json | searx/engines/currency_convert.py | def response(resp):
"""remove first and last lines to get only json"""
json_resp = resp.text[resp.text.find('\n') + 1:resp.text.rfind('\n') - 2]
results = []
try:
conversion_rate = float(json.loads(json_resp)['conversion']['converted-amount'])
except:
return results
answer = '{0}... | def response(resp):
"""remove first and last lines to get only json"""
json_resp = resp.text[resp.text.find('\n') + 1:resp.text.rfind('\n') - 2]
results = []
try:
conversion_rate = float(json.loads(json_resp)['conversion']['converted-amount'])
except:
return results
answer = '{0}... | [
"remove",
"first",
"and",
"last",
"lines",
"to",
"get",
"only",
"json"
] | asciimoo/searx | python | https://github.com/asciimoo/searx/blob/a84caa22cf947e973c10aa968d35fb2bdda6d048/searx/engines/currency_convert.py#L64-L87 | [
"def",
"response",
"(",
"resp",
")",
":",
"json_resp",
"=",
"resp",
".",
"text",
"[",
"resp",
".",
"text",
".",
"find",
"(",
"'\\n'",
")",
"+",
"1",
":",
"resp",
".",
"text",
".",
"rfind",
"(",
"'\\n'",
")",
"-",
"2",
"]",
"results",
"=",
"[",
... | a84caa22cf947e973c10aa968d35fb2bdda6d048 |
test | custom_gradient | Embeds a custom gradient into a `Tensor`.
This function works by clever application of `stop_gradient`. I.e., observe
that:
```none
h(x) = stop_gradient(f(x)) + stop_gradient(g(x)) * (x - stop_gradient(x))
```
is such that `h(x) == stop_gradient(f(x))` and
`grad[h(x), x] == stop_gradient(g(x)).`
In ... | tensorflow_probability/python/math/custom_gradient.py | def custom_gradient(fx, gx, x, fx_gx_manually_stopped=False, name=None):
"""Embeds a custom gradient into a `Tensor`.
This function works by clever application of `stop_gradient`. I.e., observe
that:
```none
h(x) = stop_gradient(f(x)) + stop_gradient(g(x)) * (x - stop_gradient(x))
```
is such that `h(x... | def custom_gradient(fx, gx, x, fx_gx_manually_stopped=False, name=None):
"""Embeds a custom gradient into a `Tensor`.
This function works by clever application of `stop_gradient`. I.e., observe
that:
```none
h(x) = stop_gradient(f(x)) + stop_gradient(g(x)) * (x - stop_gradient(x))
```
is such that `h(x... | [
"Embeds",
"a",
"custom",
"gradient",
"into",
"a",
"Tensor",
"."
] | tensorflow/probability | python | https://github.com/tensorflow/probability/blob/e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5/tensorflow_probability/python/math/custom_gradient.py#L39-L133 | [
"def",
"custom_gradient",
"(",
"fx",
",",
"gx",
",",
"x",
",",
"fx_gx_manually_stopped",
"=",
"False",
",",
"name",
"=",
"None",
")",
":",
"def",
"maybe_stop",
"(",
"x",
")",
":",
"if",
"fx_gx_manually_stopped",
":",
"return",
"x",
"return",
"tf",
".",
... | e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5 |
test | value_and_gradient | Computes `f(*xs)` and its gradients wrt to `*xs`.
Args:
f: Python `callable` to be differentiated. If `f` returns a scalar, this
scalar will be differentiated. If `f` returns a tensor or list of tensors,
by default a scalar will be computed by adding all their values to produce
a single scalar.... | tensorflow_probability/python/math/gradient.py | def value_and_gradient(f, xs, use_gradient_tape=False, name=None):
"""Computes `f(*xs)` and its gradients wrt to `*xs`.
Args:
f: Python `callable` to be differentiated. If `f` returns a scalar, this
scalar will be differentiated. If `f` returns a tensor or list of tensors,
by default a scalar will ... | def value_and_gradient(f, xs, use_gradient_tape=False, name=None):
"""Computes `f(*xs)` and its gradients wrt to `*xs`.
Args:
f: Python `callable` to be differentiated. If `f` returns a scalar, this
scalar will be differentiated. If `f` returns a tensor or list of tensors,
by default a scalar will ... | [
"Computes",
"f",
"(",
"*",
"xs",
")",
"and",
"its",
"gradients",
"wrt",
"to",
"*",
"xs",
"."
] | tensorflow/probability | python | https://github.com/tensorflow/probability/blob/e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5/tensorflow_probability/python/math/gradient.py#L30-L69 | [
"def",
"value_and_gradient",
"(",
"f",
",",
"xs",
",",
"use_gradient_tape",
"=",
"False",
",",
"name",
"=",
"None",
")",
":",
"with",
"tf",
".",
"compat",
".",
"v1",
".",
"name_scope",
"(",
"name",
",",
"'value_and_gradient'",
",",
"[",
"xs",
"]",
")",... | e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5 |
test | mvn | Convenience function to efficiently construct a MultivariateNormalDiag. | tensorflow_probability/python/mcmc/eight_schools_hmc.py | def mvn(*args, **kwargs):
"""Convenience function to efficiently construct a MultivariateNormalDiag."""
# Faster than using `tfd.MultivariateNormalDiag`.
return tfd.Independent(tfd.Normal(*args, **kwargs),
reinterpreted_batch_ndims=1) | def mvn(*args, **kwargs):
"""Convenience function to efficiently construct a MultivariateNormalDiag."""
# Faster than using `tfd.MultivariateNormalDiag`.
return tfd.Independent(tfd.Normal(*args, **kwargs),
reinterpreted_batch_ndims=1) | [
"Convenience",
"function",
"to",
"efficiently",
"construct",
"a",
"MultivariateNormalDiag",
"."
] | tensorflow/probability | python | https://github.com/tensorflow/probability/blob/e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5/tensorflow_probability/python/mcmc/eight_schools_hmc.py#L37-L41 | [
"def",
"mvn",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"# Faster than using `tfd.MultivariateNormalDiag`.",
"return",
"tfd",
".",
"Independent",
"(",
"tfd",
".",
"Normal",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
",",
"reinterpreted_batch_... | e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5 |
test | eight_schools_joint_log_prob | Eight-schools joint log-prob. | tensorflow_probability/python/mcmc/eight_schools_hmc.py | def eight_schools_joint_log_prob(
treatment_effects, treatment_stddevs,
avg_effect, avg_stddev, school_effects_standard):
"""Eight-schools joint log-prob."""
rv_avg_effect = tfd.Normal(loc=0., scale=10.)
rv_avg_stddev = tfd.Normal(loc=5., scale=1.)
rv_school_effects_standard = mvn(
loc=tf.zeros_li... | def eight_schools_joint_log_prob(
treatment_effects, treatment_stddevs,
avg_effect, avg_stddev, school_effects_standard):
"""Eight-schools joint log-prob."""
rv_avg_effect = tfd.Normal(loc=0., scale=10.)
rv_avg_stddev = tfd.Normal(loc=5., scale=1.)
rv_school_effects_standard = mvn(
loc=tf.zeros_li... | [
"Eight",
"-",
"schools",
"joint",
"log",
"-",
"prob",
"."
] | tensorflow/probability | python | https://github.com/tensorflow/probability/blob/e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5/tensorflow_probability/python/mcmc/eight_schools_hmc.py#L44-L60 | [
"def",
"eight_schools_joint_log_prob",
"(",
"treatment_effects",
",",
"treatment_stddevs",
",",
"avg_effect",
",",
"avg_stddev",
",",
"school_effects_standard",
")",
":",
"rv_avg_effect",
"=",
"tfd",
".",
"Normal",
"(",
"loc",
"=",
"0.",
",",
"scale",
"=",
"10.",
... | e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5 |
test | benchmark_eight_schools_hmc | Runs HMC on the eight-schools unnormalized posterior. | tensorflow_probability/python/mcmc/eight_schools_hmc.py | def benchmark_eight_schools_hmc(
num_results=int(5e3),
num_burnin_steps=int(3e3),
num_leapfrog_steps=3,
step_size=0.4):
"""Runs HMC on the eight-schools unnormalized posterior."""
num_schools = 8
treatment_effects = tf.constant(
[28, 8, -3, 7, -1, 1, 18, 12],
dtype=np.float32,
n... | def benchmark_eight_schools_hmc(
num_results=int(5e3),
num_burnin_steps=int(3e3),
num_leapfrog_steps=3,
step_size=0.4):
"""Runs HMC on the eight-schools unnormalized posterior."""
num_schools = 8
treatment_effects = tf.constant(
[28, 8, -3, 7, -1, 1, 18, 12],
dtype=np.float32,
n... | [
"Runs",
"HMC",
"on",
"the",
"eight",
"-",
"schools",
"unnormalized",
"posterior",
"."
] | tensorflow/probability | python | https://github.com/tensorflow/probability/blob/e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5/tensorflow_probability/python/mcmc/eight_schools_hmc.py#L63-L129 | [
"def",
"benchmark_eight_schools_hmc",
"(",
"num_results",
"=",
"int",
"(",
"5e3",
")",
",",
"num_burnin_steps",
"=",
"int",
"(",
"3e3",
")",
",",
"num_leapfrog_steps",
"=",
"3",
",",
"step_size",
"=",
"0.4",
")",
":",
"num_schools",
"=",
"8",
"treatment_effe... | e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5 |
test | expand_docstring | Decorator to programmatically expand the docstring.
Args:
**kwargs: Keyword arguments to set. For each key-value pair `k` and `v`,
the key is found as `${k}` in the docstring and replaced with `v`.
Returns:
Decorated function. | tensorflow_probability/python/util/docstring.py | def expand_docstring(**kwargs):
"""Decorator to programmatically expand the docstring.
Args:
**kwargs: Keyword arguments to set. For each key-value pair `k` and `v`,
the key is found as `${k}` in the docstring and replaced with `v`.
Returns:
Decorated function.
"""
def _fn_wrapped(fn):
"""... | def expand_docstring(**kwargs):
"""Decorator to programmatically expand the docstring.
Args:
**kwargs: Keyword arguments to set. For each key-value pair `k` and `v`,
the key is found as `${k}` in the docstring and replaced with `v`.
Returns:
Decorated function.
"""
def _fn_wrapped(fn):
"""... | [
"Decorator",
"to",
"programmatically",
"expand",
"the",
"docstring",
"."
] | tensorflow/probability | python | https://github.com/tensorflow/probability/blob/e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5/tensorflow_probability/python/util/docstring.py#L30-L51 | [
"def",
"expand_docstring",
"(",
"*",
"*",
"kwargs",
")",
":",
"def",
"_fn_wrapped",
"(",
"fn",
")",
":",
"\"\"\"Original function with modified `__doc__` attribute.\"\"\"",
"doc",
"=",
"inspect",
".",
"cleandoc",
"(",
"fn",
".",
"__doc__",
")",
"for",
"k",
",",
... | e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5 |
test | _simple_name | Infer the original name passed into a distribution constructor.
Distributions typically follow the pattern of
with.name_scope(name) as name:
super(name=name)
so we attempt to reverse the name-scope transformation to allow
addressing of RVs by the distribution's original, user-visible
name kwarg.
Args:... | tensorflow_probability/python/edward2/generated_random_variables.py | def _simple_name(distribution):
"""Infer the original name passed into a distribution constructor.
Distributions typically follow the pattern of
with.name_scope(name) as name:
super(name=name)
so we attempt to reverse the name-scope transformation to allow
addressing of RVs by the distribution's original... | def _simple_name(distribution):
"""Infer the original name passed into a distribution constructor.
Distributions typically follow the pattern of
with.name_scope(name) as name:
super(name=name)
so we attempt to reverse the name-scope transformation to allow
addressing of RVs by the distribution's original... | [
"Infer",
"the",
"original",
"name",
"passed",
"into",
"a",
"distribution",
"constructor",
"."
] | tensorflow/probability | python | https://github.com/tensorflow/probability/blob/e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5/tensorflow_probability/python/edward2/generated_random_variables.py#L43-L79 | [
"def",
"_simple_name",
"(",
"distribution",
")",
":",
"simple_name",
"=",
"distribution",
".",
"name",
"# turn 'scope/x/' into 'x'",
"if",
"simple_name",
".",
"endswith",
"(",
"'/'",
")",
":",
"simple_name",
"=",
"simple_name",
".",
"split",
"(",
"'/'",
")",
"... | e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5 |
test | _build_custom_rv | RandomVariable constructor with a dummy name argument. | tensorflow_probability/python/edward2/generated_random_variables.py | def _build_custom_rv(distribution, sample_shape, value, name):
"""RandomVariable constructor with a dummy name argument."""
# Program transformations (e.g., `make_log_joint_fn`) assume that
# the traced constructor has `name` and `value` kwargs, enabling
# them to override the value of an RV according to its na... | def _build_custom_rv(distribution, sample_shape, value, name):
"""RandomVariable constructor with a dummy name argument."""
# Program transformations (e.g., `make_log_joint_fn`) assume that
# the traced constructor has `name` and `value` kwargs, enabling
# them to override the value of an RV according to its na... | [
"RandomVariable",
"constructor",
"with",
"a",
"dummy",
"name",
"argument",
"."
] | tensorflow/probability | python | https://github.com/tensorflow/probability/blob/e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5/tensorflow_probability/python/edward2/generated_random_variables.py#L83-L94 | [
"def",
"_build_custom_rv",
"(",
"distribution",
",",
"sample_shape",
",",
"value",
",",
"name",
")",
":",
"# Program transformations (e.g., `make_log_joint_fn`) assume that",
"# the traced constructor has `name` and `value` kwargs, enabling",
"# them to override the value of an RV accord... | e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5 |
test | as_random_variable | Wrap an existing distribution as a traceable random variable.
This enables the use of custom or user-provided distributions in
Edward models. Unlike a bare `RandomVariable` object, this method
wraps the constructor so it is included in the Edward trace and its
values can be properly intercepted and overridden.... | tensorflow_probability/python/edward2/generated_random_variables.py | def as_random_variable(distribution,
sample_shape=(),
value=None):
"""Wrap an existing distribution as a traceable random variable.
This enables the use of custom or user-provided distributions in
Edward models. Unlike a bare `RandomVariable` object, this method
wr... | def as_random_variable(distribution,
sample_shape=(),
value=None):
"""Wrap an existing distribution as a traceable random variable.
This enables the use of custom or user-provided distributions in
Edward models. Unlike a bare `RandomVariable` object, this method
wr... | [
"Wrap",
"an",
"existing",
"distribution",
"as",
"a",
"traceable",
"random",
"variable",
"."
] | tensorflow/probability | python | https://github.com/tensorflow/probability/blob/e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5/tensorflow_probability/python/edward2/generated_random_variables.py#L97-L145 | [
"def",
"as_random_variable",
"(",
"distribution",
",",
"sample_shape",
"=",
"(",
")",
",",
"value",
"=",
"None",
")",
":",
"return",
"_build_custom_rv",
"(",
"distribution",
"=",
"distribution",
",",
"sample_shape",
"=",
"sample_shape",
",",
"value",
"=",
"val... | e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5 |
test | _make_random_variable | Factory function to make random variable given distribution class. | tensorflow_probability/python/edward2/generated_random_variables.py | def _make_random_variable(distribution_cls):
"""Factory function to make random variable given distribution class."""
@interceptable
@functools.wraps(distribution_cls, assigned=('__module__', '__name__'))
@docstring_util.expand_docstring(
cls=distribution_cls.__name__,
doc=inspect.cleandoc(distribu... | def _make_random_variable(distribution_cls):
"""Factory function to make random variable given distribution class."""
@interceptable
@functools.wraps(distribution_cls, assigned=('__module__', '__name__'))
@docstring_util.expand_docstring(
cls=distribution_cls.__name__,
doc=inspect.cleandoc(distribu... | [
"Factory",
"function",
"to",
"make",
"random",
"variable",
"given",
"distribution",
"class",
"."
] | tensorflow/probability | python | https://github.com/tensorflow/probability/blob/e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5/tensorflow_probability/python/edward2/generated_random_variables.py#L148-L175 | [
"def",
"_make_random_variable",
"(",
"distribution_cls",
")",
":",
"@",
"interceptable",
"@",
"functools",
".",
"wraps",
"(",
"distribution_cls",
",",
"assigned",
"=",
"(",
"'__module__'",
",",
"'__name__'",
")",
")",
"@",
"docstring_util",
".",
"expand_docstring"... | e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5 |
test | VectorExponentialLinearOperator._mode_mean_shape | Shape for the mode/mean Tensors. | tensorflow_probability/python/distributions/vector_exponential_linear_operator.py | def _mode_mean_shape(self):
"""Shape for the mode/mean Tensors."""
shape = tensorshape_util.concatenate(self.batch_shape, self.event_shape)
has_static_shape = tensorshape_util.is_fully_defined(shape)
if not has_static_shape:
shape = tf.concat([
self.batch_shape_tensor(),
self.e... | def _mode_mean_shape(self):
"""Shape for the mode/mean Tensors."""
shape = tensorshape_util.concatenate(self.batch_shape, self.event_shape)
has_static_shape = tensorshape_util.is_fully_defined(shape)
if not has_static_shape:
shape = tf.concat([
self.batch_shape_tensor(),
self.e... | [
"Shape",
"for",
"the",
"mode",
"/",
"mean",
"Tensors",
"."
] | tensorflow/probability | python | https://github.com/tensorflow/probability/blob/e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5/tensorflow_probability/python/distributions/vector_exponential_linear_operator.py#L278-L287 | [
"def",
"_mode_mean_shape",
"(",
"self",
")",
":",
"shape",
"=",
"tensorshape_util",
".",
"concatenate",
"(",
"self",
".",
"batch_shape",
",",
"self",
".",
"event_shape",
")",
"has_static_shape",
"=",
"tensorshape_util",
".",
"is_fully_defined",
"(",
"shape",
")"... | e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5 |
test | one_step_predictive | Compute one-step-ahead predictive distributions for all timesteps.
Given samples from the posterior over parameters, return the predictive
distribution over observations at each time `T`, given observations up
through time `T-1`.
Args:
model: An instance of `StructuralTimeSeries` representing a
time... | tensorflow_probability/python/sts/forecast.py | def one_step_predictive(model, observed_time_series, parameter_samples):
"""Compute one-step-ahead predictive distributions for all timesteps.
Given samples from the posterior over parameters, return the predictive
distribution over observations at each time `T`, given observations up
through time `T-1`.
Ar... | def one_step_predictive(model, observed_time_series, parameter_samples):
"""Compute one-step-ahead predictive distributions for all timesteps.
Given samples from the posterior over parameters, return the predictive
distribution over observations at each time `T`, given observations up
through time `T-1`.
Ar... | [
"Compute",
"one",
"-",
"step",
"-",
"ahead",
"predictive",
"distributions",
"for",
"all",
"timesteps",
"."
] | tensorflow/probability | python | https://github.com/tensorflow/probability/blob/e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5/tensorflow_probability/python/sts/forecast.py#L35-L169 | [
"def",
"one_step_predictive",
"(",
"model",
",",
"observed_time_series",
",",
"parameter_samples",
")",
":",
"with",
"tf",
".",
"compat",
".",
"v1",
".",
"name_scope",
"(",
"'one_step_predictive'",
",",
"values",
"=",
"[",
"observed_time_series",
",",
"parameter_s... | e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5 |
test | forecast | Construct predictive distribution over future observations.
Given samples from the posterior over parameters, return the predictive
distribution over future observations for num_steps_forecast timesteps.
Args:
model: An instance of `StructuralTimeSeries` representing a
time-series model. This represen... | tensorflow_probability/python/sts/forecast.py | def forecast(model,
observed_time_series,
parameter_samples,
num_steps_forecast):
"""Construct predictive distribution over future observations.
Given samples from the posterior over parameters, return the predictive
distribution over future observations for num_steps_forec... | def forecast(model,
observed_time_series,
parameter_samples,
num_steps_forecast):
"""Construct predictive distribution over future observations.
Given samples from the posterior over parameters, return the predictive
distribution over future observations for num_steps_forec... | [
"Construct",
"predictive",
"distribution",
"over",
"future",
"observations",
"."
] | tensorflow/probability | python | https://github.com/tensorflow/probability/blob/e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5/tensorflow_probability/python/sts/forecast.py#L172-L362 | [
"def",
"forecast",
"(",
"model",
",",
"observed_time_series",
",",
"parameter_samples",
",",
"num_steps_forecast",
")",
":",
"with",
"tf",
".",
"compat",
".",
"v1",
".",
"name_scope",
"(",
"'forecast'",
",",
"values",
"=",
"[",
"observed_time_series",
",",
"pa... | e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5 |
test | _max_mask_non_finite | Returns `max` or `mask` if `max` is not finite. | tensorflow_probability/python/internal/backend/numpy/math.py | def _max_mask_non_finite(x, axis=-1, keepdims=False, mask=0):
"""Returns `max` or `mask` if `max` is not finite."""
m = np.max(x, axis=_astuple(axis), keepdims=keepdims)
needs_masking = ~np.isfinite(m)
if needs_masking.ndim > 0:
m[needs_masking] = mask
elif needs_masking:
m = mask
return m | def _max_mask_non_finite(x, axis=-1, keepdims=False, mask=0):
"""Returns `max` or `mask` if `max` is not finite."""
m = np.max(x, axis=_astuple(axis), keepdims=keepdims)
needs_masking = ~np.isfinite(m)
if needs_masking.ndim > 0:
m[needs_masking] = mask
elif needs_masking:
m = mask
return m | [
"Returns",
"max",
"or",
"mask",
"if",
"max",
"is",
"not",
"finite",
"."
] | tensorflow/probability | python | https://github.com/tensorflow/probability/blob/e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5/tensorflow_probability/python/internal/backend/numpy/math.py#L172-L180 | [
"def",
"_max_mask_non_finite",
"(",
"x",
",",
"axis",
"=",
"-",
"1",
",",
"keepdims",
"=",
"False",
",",
"mask",
"=",
"0",
")",
":",
"m",
"=",
"np",
".",
"max",
"(",
"x",
",",
"axis",
"=",
"_astuple",
"(",
"axis",
")",
",",
"keepdims",
"=",
"ke... | e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5 |
test | _reduce_logsumexp | Computes `log(sum(exp(input_tensor))) along the specified axis. | tensorflow_probability/python/internal/backend/numpy/math.py | def _reduce_logsumexp(input_tensor, axis=None, keepdims=False, name=None): # pylint: disable=unused-argument
"""Computes `log(sum(exp(input_tensor))) along the specified axis."""
try:
return scipy_special.logsumexp(
input_tensor, axis=_astuple(axis), keepdims=keepdims)
except NotImplementedError:
... | def _reduce_logsumexp(input_tensor, axis=None, keepdims=False, name=None): # pylint: disable=unused-argument
"""Computes `log(sum(exp(input_tensor))) along the specified axis."""
try:
return scipy_special.logsumexp(
input_tensor, axis=_astuple(axis), keepdims=keepdims)
except NotImplementedError:
... | [
"Computes",
"log",
"(",
"sum",
"(",
"exp",
"(",
"input_tensor",
")))",
"along",
"the",
"specified",
"axis",
"."
] | tensorflow/probability | python | https://github.com/tensorflow/probability/blob/e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5/tensorflow_probability/python/internal/backend/numpy/math.py#L191-L202 | [
"def",
"_reduce_logsumexp",
"(",
"input_tensor",
",",
"axis",
"=",
"None",
",",
"keepdims",
"=",
"False",
",",
"name",
"=",
"None",
")",
":",
"# pylint: disable=unused-argument",
"try",
":",
"return",
"scipy_special",
".",
"logsumexp",
"(",
"input_tensor",
",",
... | e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5 |
test | assert_finite | Assert all elements of `x` are finite.
Args:
x: Numeric `Tensor`.
data: The tensors to print out if the condition is False. Defaults to
error message and first few entries of `x`.
summarize: Print this many entries of each tensor.
message: A string to prefix to the default message.
name:... | tensorflow_probability/python/internal/assert_util.py | def assert_finite(x, data=None, summarize=None, message=None, name=None):
"""Assert all elements of `x` are finite.
Args:
x: Numeric `Tensor`.
data: The tensors to print out if the condition is False. Defaults to
error message and first few entries of `x`.
summarize: Print this many entries of... | def assert_finite(x, data=None, summarize=None, message=None, name=None):
"""Assert all elements of `x` are finite.
Args:
x: Numeric `Tensor`.
data: The tensors to print out if the condition is False. Defaults to
error message and first few entries of `x`.
summarize: Print this many entries of... | [
"Assert",
"all",
"elements",
"of",
"x",
"are",
"finite",
"."
] | tensorflow/probability | python | https://github.com/tensorflow/probability/blob/e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5/tensorflow_probability/python/internal/assert_util.py#L44-L73 | [
"def",
"assert_finite",
"(",
"x",
",",
"data",
"=",
"None",
",",
"summarize",
"=",
"None",
",",
"message",
"=",
"None",
",",
"name",
"=",
"None",
")",
":",
"with",
"tf",
".",
"compat",
".",
"v2",
".",
"name_scope",
"(",
"name",
"or",
"'assert_finite'... | e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5 |
test | assert_rank_at_most | Assert `x` has rank equal to `rank` or smaller.
Example of adding a dependency to an operation:
```python
with tf.control_dependencies([tf.assert_rank_at_most(x, 2)]):
output = tf.reduce_sum(x)
```
Args:
x: Numeric `Tensor`.
rank: Scalar `Tensor`.
data: The tensors to print out if the co... | tensorflow_probability/python/internal/assert_util.py | def assert_rank_at_most(x, rank, data=None, summarize=None, message=None,
name=None):
"""Assert `x` has rank equal to `rank` or smaller.
Example of adding a dependency to an operation:
```python
with tf.control_dependencies([tf.assert_rank_at_most(x, 2)]):
output = tf.reduce_sum(x)... | def assert_rank_at_most(x, rank, data=None, summarize=None, message=None,
name=None):
"""Assert `x` has rank equal to `rank` or smaller.
Example of adding a dependency to an operation:
```python
with tf.control_dependencies([tf.assert_rank_at_most(x, 2)]):
output = tf.reduce_sum(x)... | [
"Assert",
"x",
"has",
"rank",
"equal",
"to",
"rank",
"or",
"smaller",
"."
] | tensorflow/probability | python | https://github.com/tensorflow/probability/blob/e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5/tensorflow_probability/python/internal/assert_util.py#L76-L106 | [
"def",
"assert_rank_at_most",
"(",
"x",
",",
"rank",
",",
"data",
"=",
"None",
",",
"summarize",
"=",
"None",
",",
"message",
"=",
"None",
",",
"name",
"=",
"None",
")",
":",
"with",
"tf",
".",
"compat",
".",
"v2",
".",
"name_scope",
"(",
"name",
"... | e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5 |
test | _event_size | Computes the number of elements in a tensor with shape `event_shape`.
Args:
event_shape: A tensor shape.
name: The name to use for the tensor op to compute the number of elements
(if such an op needs to be created).
Returns:
event_size: The number of elements in `tensor_shape`. Returns a numpy ... | tensorflow_probability/python/layers/distribution_layer.py | def _event_size(event_shape, name=None):
"""Computes the number of elements in a tensor with shape `event_shape`.
Args:
event_shape: A tensor shape.
name: The name to use for the tensor op to compute the number of elements
(if such an op needs to be created).
Returns:
event_size: The number of... | def _event_size(event_shape, name=None):
"""Computes the number of elements in a tensor with shape `event_shape`.
Args:
event_shape: A tensor shape.
name: The name to use for the tensor op to compute the number of elements
(if such an op needs to be created).
Returns:
event_size: The number of... | [
"Computes",
"the",
"number",
"of",
"elements",
"in",
"a",
"tensor",
"with",
"shape",
"event_shape",
"."
] | tensorflow/probability | python | https://github.com/tensorflow/probability/blob/e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5/tensorflow_probability/python/layers/distribution_layer.py#L65-L86 | [
"def",
"_event_size",
"(",
"event_shape",
",",
"name",
"=",
"None",
")",
":",
"with",
"tf",
".",
"compat",
".",
"v1",
".",
"name_scope",
"(",
"name",
",",
"'event_size'",
",",
"[",
"event_shape",
"]",
")",
":",
"event_shape",
"=",
"tf",
".",
"convert_t... | e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5 |
test | _eval_all_one_hot | OneHotCategorical helper computing probs, cdf, etc over its support. | tensorflow_probability/python/layers/distribution_layer.py | def _eval_all_one_hot(fn, dist, name=None):
"""OneHotCategorical helper computing probs, cdf, etc over its support."""
with tf.compat.v1.name_scope(name, 'eval_all_one_hot'):
event_size = dist.event_shape_tensor()[-1]
batch_ndims = tf.size(input=dist.batch_shape_tensor())
# Reshape `eye(d)` to: `[d] + [... | def _eval_all_one_hot(fn, dist, name=None):
"""OneHotCategorical helper computing probs, cdf, etc over its support."""
with tf.compat.v1.name_scope(name, 'eval_all_one_hot'):
event_size = dist.event_shape_tensor()[-1]
batch_ndims = tf.size(input=dist.batch_shape_tensor())
# Reshape `eye(d)` to: `[d] + [... | [
"OneHotCategorical",
"helper",
"computing",
"probs",
"cdf",
"etc",
"over",
"its",
"support",
"."
] | tensorflow/probability | python | https://github.com/tensorflow/probability/blob/e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5/tensorflow_probability/python/layers/distribution_layer.py#L754-L768 | [
"def",
"_eval_all_one_hot",
"(",
"fn",
",",
"dist",
",",
"name",
"=",
"None",
")",
":",
"with",
"tf",
".",
"compat",
".",
"v1",
".",
"name_scope",
"(",
"name",
",",
"'eval_all_one_hot'",
")",
":",
"event_size",
"=",
"dist",
".",
"event_shape_tensor",
"("... | e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5 |
test | _make_kl_divergence_fn | Creates a callable computing `KL[a,b]` from `a`, a `tfd.Distribution`. | tensorflow_probability/python/layers/distribution_layer.py | def _make_kl_divergence_fn(
distribution_b,
use_exact_kl=False,
test_points_reduce_axis=(), # `None` == "all"; () == "none".
test_points_fn=tf.convert_to_tensor,
weight=None):
"""Creates a callable computing `KL[a,b]` from `a`, a `tfd.Distribution`."""
if use_exact_kl is None:
kl_divergenc... | def _make_kl_divergence_fn(
distribution_b,
use_exact_kl=False,
test_points_reduce_axis=(), # `None` == "all"; () == "none".
test_points_fn=tf.convert_to_tensor,
weight=None):
"""Creates a callable computing `KL[a,b]` from `a`, a `tfd.Distribution`."""
if use_exact_kl is None:
kl_divergenc... | [
"Creates",
"a",
"callable",
"computing",
"KL",
"[",
"a",
"b",
"]",
"from",
"a",
"a",
"tfd",
".",
"Distribution",
"."
] | tensorflow/probability | python | https://github.com/tensorflow/probability/blob/e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5/tensorflow_probability/python/layers/distribution_layer.py#L1309-L1349 | [
"def",
"_make_kl_divergence_fn",
"(",
"distribution_b",
",",
"use_exact_kl",
"=",
"False",
",",
"test_points_reduce_axis",
"=",
"(",
")",
",",
"# `None` == \"all\"; () == \"none\".",
"test_points_fn",
"=",
"tf",
".",
"convert_to_tensor",
",",
"weight",
"=",
"None",
")... | e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5 |
test | _get_convert_to_tensor_fn | Return a convert-to-tensor func, given a name, config, callable, etc. | tensorflow_probability/python/layers/distribution_layer.py | def _get_convert_to_tensor_fn(identifier):
"""Return a convert-to-tensor func, given a name, config, callable, etc."""
if identifier is None:
return None
if isinstance(identifier, six.string_types):
identifier = str(identifier)
return _deserialize(identifier)
if isinstance(identifier, dict):
r... | def _get_convert_to_tensor_fn(identifier):
"""Return a convert-to-tensor func, given a name, config, callable, etc."""
if identifier is None:
return None
if isinstance(identifier, six.string_types):
identifier = str(identifier)
return _deserialize(identifier)
if isinstance(identifier, dict):
r... | [
"Return",
"a",
"convert",
"-",
"to",
"-",
"tensor",
"func",
"given",
"a",
"name",
"config",
"callable",
"etc",
"."
] | tensorflow/probability | python | https://github.com/tensorflow/probability/blob/e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5/tensorflow_probability/python/layers/distribution_layer.py#L1912-L1930 | [
"def",
"_get_convert_to_tensor_fn",
"(",
"identifier",
")",
":",
"if",
"identifier",
"is",
"None",
":",
"return",
"None",
"if",
"isinstance",
"(",
"identifier",
",",
"six",
".",
"string_types",
")",
":",
"identifier",
"=",
"str",
"(",
"identifier",
")",
"ret... | e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5 |
test | DistributionLambda.get_config | Returns the config of this layer.
This Layer's `make_distribution_fn` is serialized via a library built on
Python pickle. This serialization of Python functions is provided for
convenience, but:
1. The use of this format for long-term storage of models is discouraged.
In particular, it may... | tensorflow_probability/python/layers/distribution_layer.py | def get_config(self):
"""Returns the config of this layer.
This Layer's `make_distribution_fn` is serialized via a library built on
Python pickle. This serialization of Python functions is provided for
convenience, but:
1. The use of this format for long-term storage of models is discouraged.
... | def get_config(self):
"""Returns the config of this layer.
This Layer's `make_distribution_fn` is serialized via a library built on
Python pickle. This serialization of Python functions is provided for
convenience, but:
1. The use of this format for long-term storage of models is discouraged.
... | [
"Returns",
"the",
"config",
"of",
"this",
"layer",
"."
] | tensorflow/probability | python | https://github.com/tensorflow/probability/blob/e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5/tensorflow_probability/python/layers/distribution_layer.py#L221-L258 | [
"def",
"get_config",
"(",
"self",
")",
":",
"config",
"=",
"{",
"'make_distribution_fn'",
":",
"_serialize_function",
"(",
"self",
".",
"_make_distribution_fn",
")",
",",
"'convert_to_tensor_fn'",
":",
"_serialize",
"(",
"self",
".",
"_convert_to_tensor_fn",
")",
... | e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5 |
test | MultivariateNormalTriL.new | Create the distribution instance from a `params` vector. | tensorflow_probability/python/layers/distribution_layer.py | def new(params, event_size, validate_args=False, name=None):
"""Create the distribution instance from a `params` vector."""
with tf.compat.v1.name_scope(name, 'MultivariateNormalTriL',
[params, event_size]):
params = tf.convert_to_tensor(value=params, name='params')
... | def new(params, event_size, validate_args=False, name=None):
"""Create the distribution instance from a `params` vector."""
with tf.compat.v1.name_scope(name, 'MultivariateNormalTriL',
[params, event_size]):
params = tf.convert_to_tensor(value=params, name='params')
... | [
"Create",
"the",
"distribution",
"instance",
"from",
"a",
"params",
"vector",
"."
] | tensorflow/probability | python | https://github.com/tensorflow/probability/blob/e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5/tensorflow_probability/python/layers/distribution_layer.py#L349-L360 | [
"def",
"new",
"(",
"params",
",",
"event_size",
",",
"validate_args",
"=",
"False",
",",
"name",
"=",
"None",
")",
":",
"with",
"tf",
".",
"compat",
".",
"v1",
".",
"name_scope",
"(",
"name",
",",
"'MultivariateNormalTriL'",
",",
"[",
"params",
",",
"e... | e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5 |
test | MultivariateNormalTriL.params_size | The number of `params` needed to create a single distribution. | tensorflow_probability/python/layers/distribution_layer.py | def params_size(event_size, name=None):
"""The number of `params` needed to create a single distribution."""
with tf.compat.v1.name_scope(name, 'MultivariateNormalTriL_params_size',
[event_size]):
return event_size + event_size * (event_size + 1) // 2 | def params_size(event_size, name=None):
"""The number of `params` needed to create a single distribution."""
with tf.compat.v1.name_scope(name, 'MultivariateNormalTriL_params_size',
[event_size]):
return event_size + event_size * (event_size + 1) // 2 | [
"The",
"number",
"of",
"params",
"needed",
"to",
"create",
"a",
"single",
"distribution",
"."
] | tensorflow/probability | python | https://github.com/tensorflow/probability/blob/e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5/tensorflow_probability/python/layers/distribution_layer.py#L363-L367 | [
"def",
"params_size",
"(",
"event_size",
",",
"name",
"=",
"None",
")",
":",
"with",
"tf",
".",
"compat",
".",
"v1",
".",
"name_scope",
"(",
"name",
",",
"'MultivariateNormalTriL_params_size'",
",",
"[",
"event_size",
"]",
")",
":",
"return",
"event_size",
... | e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5 |
test | OneHotCategorical.new | Create the distribution instance from a `params` vector. | tensorflow_probability/python/layers/distribution_layer.py | def new(params, event_size, dtype=None, validate_args=False, name=None):
"""Create the distribution instance from a `params` vector."""
with tf.compat.v1.name_scope(name, 'OneHotCategorical',
[params, event_size]):
return tfd.OneHotCategorical(
logits=params,
... | def new(params, event_size, dtype=None, validate_args=False, name=None):
"""Create the distribution instance from a `params` vector."""
with tf.compat.v1.name_scope(name, 'OneHotCategorical',
[params, event_size]):
return tfd.OneHotCategorical(
logits=params,
... | [
"Create",
"the",
"distribution",
"instance",
"from",
"a",
"params",
"vector",
"."
] | tensorflow/probability | python | https://github.com/tensorflow/probability/blob/e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5/tensorflow_probability/python/layers/distribution_layer.py#L456-L463 | [
"def",
"new",
"(",
"params",
",",
"event_size",
",",
"dtype",
"=",
"None",
",",
"validate_args",
"=",
"False",
",",
"name",
"=",
"None",
")",
":",
"with",
"tf",
".",
"compat",
".",
"v1",
".",
"name_scope",
"(",
"name",
",",
"'OneHotCategorical'",
",",
... | e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5 |
test | CategoricalMixtureOfOneHotCategorical.new | Create the distribution instance from a `params` vector. | tensorflow_probability/python/layers/distribution_layer.py | def new(params, event_size, num_components,
dtype=None, validate_args=False, name=None):
"""Create the distribution instance from a `params` vector."""
with tf.compat.v1.name_scope(name, 'CategoricalMixtureOfOneHotCategorical',
[params, event_size, num_components]):
... | def new(params, event_size, num_components,
dtype=None, validate_args=False, name=None):
"""Create the distribution instance from a `params` vector."""
with tf.compat.v1.name_scope(name, 'CategoricalMixtureOfOneHotCategorical',
[params, event_size, num_components]):
... | [
"Create",
"the",
"distribution",
"instance",
"from",
"a",
"params",
"vector",
"."
] | tensorflow/probability | python | https://github.com/tensorflow/probability/blob/e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5/tensorflow_probability/python/layers/distribution_layer.py#L563-L583 | [
"def",
"new",
"(",
"params",
",",
"event_size",
",",
"num_components",
",",
"dtype",
"=",
"None",
",",
"validate_args",
"=",
"False",
",",
"name",
"=",
"None",
")",
":",
"with",
"tf",
".",
"compat",
".",
"v1",
".",
"name_scope",
"(",
"name",
",",
"'C... | e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5 |
test | CategoricalMixtureOfOneHotCategorical.params_size | The number of `params` needed to create a single distribution. | tensorflow_probability/python/layers/distribution_layer.py | def params_size(event_size, num_components, name=None):
"""The number of `params` needed to create a single distribution."""
with tf.compat.v1.name_scope(
name, 'CategoricalMixtureOfOneHotCategorical_params_size',
[event_size, num_components]):
return MixtureSameFamily.params_size(
... | def params_size(event_size, num_components, name=None):
"""The number of `params` needed to create a single distribution."""
with tf.compat.v1.name_scope(
name, 'CategoricalMixtureOfOneHotCategorical_params_size',
[event_size, num_components]):
return MixtureSameFamily.params_size(
... | [
"The",
"number",
"of",
"params",
"needed",
"to",
"create",
"a",
"single",
"distribution",
"."
] | tensorflow/probability | python | https://github.com/tensorflow/probability/blob/e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5/tensorflow_probability/python/layers/distribution_layer.py#L586-L594 | [
"def",
"params_size",
"(",
"event_size",
",",
"num_components",
",",
"name",
"=",
"None",
")",
":",
"with",
"tf",
".",
"compat",
".",
"v1",
".",
"name_scope",
"(",
"name",
",",
"'CategoricalMixtureOfOneHotCategorical_params_size'",
",",
"[",
"event_size",
",",
... | e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5 |
test | IndependentBernoulli.new | Create the distribution instance from a `params` vector. | tensorflow_probability/python/layers/distribution_layer.py | def new(params, event_shape=(), dtype=None, validate_args=False, name=None):
"""Create the distribution instance from a `params` vector."""
with tf.compat.v1.name_scope(name, 'IndependentBernoulli',
[params, event_shape]):
params = tf.convert_to_tensor(value=params, name='... | def new(params, event_shape=(), dtype=None, validate_args=False, name=None):
"""Create the distribution instance from a `params` vector."""
with tf.compat.v1.name_scope(name, 'IndependentBernoulli',
[params, event_shape]):
params = tf.convert_to_tensor(value=params, name='... | [
"Create",
"the",
"distribution",
"instance",
"from",
"a",
"params",
"vector",
"."
] | tensorflow/probability | python | https://github.com/tensorflow/probability/blob/e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5/tensorflow_probability/python/layers/distribution_layer.py#L696-L720 | [
"def",
"new",
"(",
"params",
",",
"event_shape",
"=",
"(",
")",
",",
"dtype",
"=",
"None",
",",
"validate_args",
"=",
"False",
",",
"name",
"=",
"None",
")",
":",
"with",
"tf",
".",
"compat",
".",
"v1",
".",
"name_scope",
"(",
"name",
",",
"'Indepe... | e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5 |
test | IndependentBernoulli.get_config | Returns the config of this layer.
NOTE: At the moment, this configuration can only be serialized if the
Layer's `convert_to_tensor_fn` is a serializable Keras object (i.e.,
implements `get_config`) or one of the standard values:
- `Distribution.sample` (or `"sample"`)
- `Distribution.mean` (or `"... | tensorflow_probability/python/layers/distribution_layer.py | def get_config(self):
"""Returns the config of this layer.
NOTE: At the moment, this configuration can only be serialized if the
Layer's `convert_to_tensor_fn` is a serializable Keras object (i.e.,
implements `get_config`) or one of the standard values:
- `Distribution.sample` (or `"sample"`)
... | def get_config(self):
"""Returns the config of this layer.
NOTE: At the moment, this configuration can only be serialized if the
Layer's `convert_to_tensor_fn` is a serializable Keras object (i.e.,
implements `get_config`) or one of the standard values:
- `Distribution.sample` (or `"sample"`)
... | [
"Returns",
"the",
"config",
"of",
"this",
"layer",
"."
] | tensorflow/probability | python | https://github.com/tensorflow/probability/blob/e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5/tensorflow_probability/python/layers/distribution_layer.py#L732-L751 | [
"def",
"get_config",
"(",
"self",
")",
":",
"config",
"=",
"{",
"'event_shape'",
":",
"self",
".",
"_event_shape",
",",
"'convert_to_tensor_fn'",
":",
"_serialize",
"(",
"self",
".",
"_convert_to_tensor_fn",
")",
",",
"'sample_dtype'",
":",
"self",
".",
"_samp... | e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5 |
test | IndependentLogistic.new | Create the distribution instance from a `params` vector. | tensorflow_probability/python/layers/distribution_layer.py | def new(params, event_shape=(), validate_args=False, name=None):
"""Create the distribution instance from a `params` vector."""
with tf.compat.v1.name_scope(name, 'IndependentLogistic',
[params, event_shape]):
params = tf.convert_to_tensor(value=params, name='params')
... | def new(params, event_shape=(), validate_args=False, name=None):
"""Create the distribution instance from a `params` vector."""
with tf.compat.v1.name_scope(name, 'IndependentLogistic',
[params, event_shape]):
params = tf.convert_to_tensor(value=params, name='params')
... | [
"Create",
"the",
"distribution",
"instance",
"from",
"a",
"params",
"vector",
"."
] | tensorflow/probability | python | https://github.com/tensorflow/probability/blob/e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5/tensorflow_probability/python/layers/distribution_layer.py#L834-L855 | [
"def",
"new",
"(",
"params",
",",
"event_shape",
"=",
"(",
")",
",",
"validate_args",
"=",
"False",
",",
"name",
"=",
"None",
")",
":",
"with",
"tf",
".",
"compat",
".",
"v1",
".",
"name_scope",
"(",
"name",
",",
"'IndependentLogistic'",
",",
"[",
"p... | e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5 |
test | IndependentNormal.params_size | The number of `params` needed to create a single distribution. | tensorflow_probability/python/layers/distribution_layer.py | def params_size(event_shape=(), name=None):
"""The number of `params` needed to create a single distribution."""
with tf.compat.v1.name_scope(name, 'IndependentNormal_params_size',
[event_shape]):
event_shape = tf.convert_to_tensor(
value=event_shape, name='event... | def params_size(event_shape=(), name=None):
"""The number of `params` needed to create a single distribution."""
with tf.compat.v1.name_scope(name, 'IndependentNormal_params_size',
[event_shape]):
event_shape = tf.convert_to_tensor(
value=event_shape, name='event... | [
"The",
"number",
"of",
"params",
"needed",
"to",
"create",
"a",
"single",
"distribution",
"."
] | tensorflow/probability | python | https://github.com/tensorflow/probability/blob/e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5/tensorflow_probability/python/layers/distribution_layer.py#L975-L982 | [
"def",
"params_size",
"(",
"event_shape",
"=",
"(",
")",
",",
"name",
"=",
"None",
")",
":",
"with",
"tf",
".",
"compat",
".",
"v1",
".",
"name_scope",
"(",
"name",
",",
"'IndependentNormal_params_size'",
",",
"[",
"event_shape",
"]",
")",
":",
"event_sh... | e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5 |
test | IndependentPoisson.new | Create the distribution instance from a `params` vector. | tensorflow_probability/python/layers/distribution_layer.py | def new(params, event_shape=(), validate_args=False, name=None):
"""Create the distribution instance from a `params` vector."""
with tf.compat.v1.name_scope(name, 'IndependentPoisson',
[params, event_shape]):
params = tf.convert_to_tensor(value=params, name='params')
... | def new(params, event_shape=(), validate_args=False, name=None):
"""Create the distribution instance from a `params` vector."""
with tf.compat.v1.name_scope(name, 'IndependentPoisson',
[params, event_shape]):
params = tf.convert_to_tensor(value=params, name='params')
... | [
"Create",
"the",
"distribution",
"instance",
"from",
"a",
"params",
"vector",
"."
] | tensorflow/probability | python | https://github.com/tensorflow/probability/blob/e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5/tensorflow_probability/python/layers/distribution_layer.py#L1084-L1103 | [
"def",
"new",
"(",
"params",
",",
"event_shape",
"=",
"(",
")",
",",
"validate_args",
"=",
"False",
",",
"name",
"=",
"None",
")",
":",
"with",
"tf",
".",
"compat",
".",
"v1",
".",
"name_scope",
"(",
"name",
",",
"'IndependentPoisson'",
",",
"[",
"pa... | e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5 |
test | MixtureSameFamily.new | Create the distribution instance from a `params` vector. | tensorflow_probability/python/layers/distribution_layer.py | def new(params, num_components, component_layer,
validate_args=False, name=None):
"""Create the distribution instance from a `params` vector."""
with tf.compat.v1.name_scope(name, 'MixtureSameFamily',
[params, num_components, component_layer]):
params = tf.conver... | def new(params, num_components, component_layer,
validate_args=False, name=None):
"""Create the distribution instance from a `params` vector."""
with tf.compat.v1.name_scope(name, 'MixtureSameFamily',
[params, num_components, component_layer]):
params = tf.conver... | [
"Create",
"the",
"distribution",
"instance",
"from",
"a",
"params",
"vector",
"."
] | tensorflow/probability | python | https://github.com/tensorflow/probability/blob/e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5/tensorflow_probability/python/layers/distribution_layer.py#L1427-L1448 | [
"def",
"new",
"(",
"params",
",",
"num_components",
",",
"component_layer",
",",
"validate_args",
"=",
"False",
",",
"name",
"=",
"None",
")",
":",
"with",
"tf",
".",
"compat",
".",
"v1",
".",
"name_scope",
"(",
"name",
",",
"'MixtureSameFamily'",
",",
"... | e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5 |
test | MixtureSameFamily.params_size | Number of `params` needed to create a `MixtureSameFamily` distribution.
Arguments:
num_components: Number of component distributions in the mixture
distribution.
component_params_size: Number of parameters needed to create a single
component distribution.
name: The name to use for... | tensorflow_probability/python/layers/distribution_layer.py | def params_size(num_components, component_params_size, name=None):
"""Number of `params` needed to create a `MixtureSameFamily` distribution.
Arguments:
num_components: Number of component distributions in the mixture
distribution.
component_params_size: Number of parameters needed to creat... | def params_size(num_components, component_params_size, name=None):
"""Number of `params` needed to create a `MixtureSameFamily` distribution.
Arguments:
num_components: Number of component distributions in the mixture
distribution.
component_params_size: Number of parameters needed to creat... | [
"Number",
"of",
"params",
"needed",
"to",
"create",
"a",
"MixtureSameFamily",
"distribution",
"."
] | tensorflow/probability | python | https://github.com/tensorflow/probability/blob/e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5/tensorflow_probability/python/layers/distribution_layer.py#L1451-L1477 | [
"def",
"params_size",
"(",
"num_components",
",",
"component_params_size",
",",
"name",
"=",
"None",
")",
":",
"with",
"tf",
".",
"compat",
".",
"v1",
".",
"name_scope",
"(",
"name",
",",
"'MixtureSameFamily_params_size'",
",",
"[",
"num_components",
",",
"com... | e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5 |
test | MixtureNormal.params_size | The number of `params` needed to create a single distribution. | tensorflow_probability/python/layers/distribution_layer.py | def params_size(num_components, event_shape=(), name=None):
"""The number of `params` needed to create a single distribution."""
return MixtureSameFamily.params_size(
num_components,
IndependentNormal.params_size(event_shape, name=name),
name=name) | def params_size(num_components, event_shape=(), name=None):
"""The number of `params` needed to create a single distribution."""
return MixtureSameFamily.params_size(
num_components,
IndependentNormal.params_size(event_shape, name=name),
name=name) | [
"The",
"number",
"of",
"params",
"needed",
"to",
"create",
"a",
"single",
"distribution",
"."
] | tensorflow/probability | python | https://github.com/tensorflow/probability/blob/e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5/tensorflow_probability/python/layers/distribution_layer.py#L1574-L1579 | [
"def",
"params_size",
"(",
"num_components",
",",
"event_shape",
"=",
"(",
")",
",",
"name",
"=",
"None",
")",
":",
"return",
"MixtureSameFamily",
".",
"params_size",
"(",
"num_components",
",",
"IndependentNormal",
".",
"params_size",
"(",
"event_shape",
",",
... | e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5 |
test | MixtureLogistic.new | Create the distribution instance from a `params` vector. | tensorflow_probability/python/layers/distribution_layer.py | def new(params, num_components, event_shape=(),
validate_args=False, name=None):
"""Create the distribution instance from a `params` vector."""
return MixtureSameFamily.new(
params,
num_components,
IndependentLogistic(
event_shape, validate_args=validate_args, name=... | def new(params, num_components, event_shape=(),
validate_args=False, name=None):
"""Create the distribution instance from a `params` vector."""
return MixtureSameFamily.new(
params,
num_components,
IndependentLogistic(
event_shape, validate_args=validate_args, name=... | [
"Create",
"the",
"distribution",
"instance",
"from",
"a",
"params",
"vector",
"."
] | tensorflow/probability | python | https://github.com/tensorflow/probability/blob/e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5/tensorflow_probability/python/layers/distribution_layer.py#L1686-L1695 | [
"def",
"new",
"(",
"params",
",",
"num_components",
",",
"event_shape",
"=",
"(",
")",
",",
"validate_args",
"=",
"False",
",",
"name",
"=",
"None",
")",
":",
"return",
"MixtureSameFamily",
".",
"new",
"(",
"params",
",",
"num_components",
",",
"Independen... | e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5 |
test | MixtureLogistic.params_size | The number of `params` needed to create a single distribution. | tensorflow_probability/python/layers/distribution_layer.py | def params_size(num_components, event_shape=(), name=None):
"""The number of `params` needed to create a single distribution."""
return MixtureSameFamily.params_size(
num_components,
IndependentLogistic.params_size(event_shape, name=name),
name=name) | def params_size(num_components, event_shape=(), name=None):
"""The number of `params` needed to create a single distribution."""
return MixtureSameFamily.params_size(
num_components,
IndependentLogistic.params_size(event_shape, name=name),
name=name) | [
"The",
"number",
"of",
"params",
"needed",
"to",
"create",
"a",
"single",
"distribution",
"."
] | tensorflow/probability | python | https://github.com/tensorflow/probability/blob/e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5/tensorflow_probability/python/layers/distribution_layer.py#L1698-L1703 | [
"def",
"params_size",
"(",
"num_components",
",",
"event_shape",
"=",
"(",
")",
",",
"name",
"=",
"None",
")",
":",
"return",
"MixtureSameFamily",
".",
"params_size",
"(",
"num_components",
",",
"IndependentLogistic",
".",
"params_size",
"(",
"event_shape",
",",... | e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5 |
test | get_next_interceptor | Yields the top-most interceptor on the thread-local interceptor stack.
Operations may be intercepted by multiple nested interceptors. Once reached,
an operation can be forwarded through nested interceptors until resolved.
To allow for nesting, implement interceptors by re-wrapping their first
argument (`f`) as... | tensorflow_probability/python/edward2/interceptor.py | def get_next_interceptor():
"""Yields the top-most interceptor on the thread-local interceptor stack.
Operations may be intercepted by multiple nested interceptors. Once reached,
an operation can be forwarded through nested interceptors until resolved.
To allow for nesting, implement interceptors by re-wrappin... | def get_next_interceptor():
"""Yields the top-most interceptor on the thread-local interceptor stack.
Operations may be intercepted by multiple nested interceptors. Once reached,
an operation can be forwarded through nested interceptors until resolved.
To allow for nesting, implement interceptors by re-wrappin... | [
"Yields",
"the",
"top",
"-",
"most",
"interceptor",
"on",
"the",
"thread",
"-",
"local",
"interceptor",
"stack",
"."
] | tensorflow/probability | python | https://github.com/tensorflow/probability/blob/e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5/tensorflow_probability/python/edward2/interceptor.py#L96-L172 | [
"def",
"get_next_interceptor",
"(",
")",
":",
"try",
":",
"interceptor",
"=",
"_interceptor_stack",
".",
"stack",
".",
"pop",
"(",
")",
"yield",
"interceptor",
"finally",
":",
"_interceptor_stack",
".",
"stack",
".",
"append",
"(",
"interceptor",
")"
] | e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5 |
test | interceptable | Decorator that wraps `func` so that its execution is intercepted.
The wrapper passes `func` to the interceptor for the current thread.
If there is no next interceptor, we perform an "immediate" call to `func`.
That is, `func` terminates without forwarding its execution to another
interceptor.
Args:
fun... | tensorflow_probability/python/edward2/interceptor.py | def interceptable(func):
"""Decorator that wraps `func` so that its execution is intercepted.
The wrapper passes `func` to the interceptor for the current thread.
If there is no next interceptor, we perform an "immediate" call to `func`.
That is, `func` terminates without forwarding its execution to another
... | def interceptable(func):
"""Decorator that wraps `func` so that its execution is intercepted.
The wrapper passes `func` to the interceptor for the current thread.
If there is no next interceptor, we perform an "immediate" call to `func`.
That is, `func` terminates without forwarding its execution to another
... | [
"Decorator",
"that",
"wraps",
"func",
"so",
"that",
"its",
"execution",
"is",
"intercepted",
"."
] | tensorflow/probability | python | https://github.com/tensorflow/probability/blob/e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5/tensorflow_probability/python/edward2/interceptor.py#L175-L195 | [
"def",
"interceptable",
"(",
"func",
")",
":",
"@",
"functools",
".",
"wraps",
"(",
"func",
")",
"def",
"func_wrapped",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"with",
"get_next_interceptor",
"(",
")",
"as",
"interceptor",
":",
"return",
"... | e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5 |
test | tape | Context manager for recording interceptable executions onto a tape.
Similar to `tf.GradientTape`, operations are recorded if they are executed
within this context manager. In addition, the operation must be registered
(wrapped) as `ed.interceptable`.
Yields:
tape: OrderedDict where operations are recorded... | tensorflow_probability/python/edward2/interceptor.py | def tape():
"""Context manager for recording interceptable executions onto a tape.
Similar to `tf.GradientTape`, operations are recorded if they are executed
within this context manager. In addition, the operation must be registered
(wrapped) as `ed.interceptable`.
Yields:
tape: OrderedDict where operat... | def tape():
"""Context manager for recording interceptable executions onto a tape.
Similar to `tf.GradientTape`, operations are recorded if they are executed
within this context manager. In addition, the operation must be registered
(wrapped) as `ed.interceptable`.
Yields:
tape: OrderedDict where operat... | [
"Context",
"manager",
"for",
"recording",
"interceptable",
"executions",
"onto",
"a",
"tape",
"."
] | tensorflow/probability | python | https://github.com/tensorflow/probability/blob/e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5/tensorflow_probability/python/edward2/interceptor.py#L199-L245 | [
"def",
"tape",
"(",
")",
":",
"tape_data",
"=",
"collections",
".",
"OrderedDict",
"(",
"{",
"}",
")",
"def",
"record",
"(",
"f",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"\"\"\"Records execution to a tape.\"\"\"",
"name",
"=",
"kwargs",
".",... | e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5 |
test | toy_logistic_data | Generates synthetic data for binary classification.
Args:
num_examples: The number of samples to generate (scalar Python `int`).
input_size: The input space dimension (scalar Python `int`).
weights_prior_stddev: The prior standard deviation of the weight
vector. (scalar Python `float`).
Returns:... | tensorflow_probability/examples/logistic_regression.py | def toy_logistic_data(num_examples, input_size=2, weights_prior_stddev=5.0):
"""Generates synthetic data for binary classification.
Args:
num_examples: The number of samples to generate (scalar Python `int`).
input_size: The input space dimension (scalar Python `int`).
weights_prior_stddev: The prior s... | def toy_logistic_data(num_examples, input_size=2, weights_prior_stddev=5.0):
"""Generates synthetic data for binary classification.
Args:
num_examples: The number of samples to generate (scalar Python `int`).
input_size: The input space dimension (scalar Python `int`).
weights_prior_stddev: The prior s... | [
"Generates",
"synthetic",
"data",
"for",
"binary",
"classification",
"."
] | tensorflow/probability | python | https://github.com/tensorflow/probability/blob/e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5/tensorflow_probability/examples/logistic_regression.py#L58-L86 | [
"def",
"toy_logistic_data",
"(",
"num_examples",
",",
"input_size",
"=",
"2",
",",
"weights_prior_stddev",
"=",
"5.0",
")",
":",
"random_weights",
"=",
"weights_prior_stddev",
"*",
"np",
".",
"random",
".",
"randn",
"(",
"input_size",
")",
"random_bias",
"=",
... | e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5 |
test | visualize_decision | Utility method to visualize decision boundaries in R^2.
Args:
features: Input points, as a Numpy `array` of shape `[num_examples, 2]`.
labels: Numpy `float`-like array of shape `[num_examples, 1]` giving a
label for each point.
true_w_b: A `tuple` `(w, b)` where `w` is a Numpy array of
shape... | tensorflow_probability/examples/logistic_regression.py | def visualize_decision(features, labels, true_w_b, candidate_w_bs, fname):
"""Utility method to visualize decision boundaries in R^2.
Args:
features: Input points, as a Numpy `array` of shape `[num_examples, 2]`.
labels: Numpy `float`-like array of shape `[num_examples, 1]` giving a
label for each po... | def visualize_decision(features, labels, true_w_b, candidate_w_bs, fname):
"""Utility method to visualize decision boundaries in R^2.
Args:
features: Input points, as a Numpy `array` of shape `[num_examples, 2]`.
labels: Numpy `float`-like array of shape `[num_examples, 1]` giving a
label for each po... | [
"Utility",
"method",
"to",
"visualize",
"decision",
"boundaries",
"in",
"R^2",
"."
] | tensorflow/probability | python | https://github.com/tensorflow/probability/blob/e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5/tensorflow_probability/examples/logistic_regression.py#L89-L131 | [
"def",
"visualize_decision",
"(",
"features",
",",
"labels",
",",
"true_w_b",
",",
"candidate_w_bs",
",",
"fname",
")",
":",
"fig",
"=",
"figure",
".",
"Figure",
"(",
"figsize",
"=",
"(",
"6",
",",
"6",
")",
")",
"canvas",
"=",
"backend_agg",
".",
"Fig... | e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5 |
test | build_input_pipeline | Build a Dataset iterator for supervised classification.
Args:
x: Numpy `array` of features, indexed by the first dimension.
y: Numpy `array` of labels, with the same first dimension as `x`.
batch_size: Number of elements in each training batch.
Returns:
batch_features: `Tensor` feed features, of ... | tensorflow_probability/examples/logistic_regression.py | def build_input_pipeline(x, y, batch_size):
"""Build a Dataset iterator for supervised classification.
Args:
x: Numpy `array` of features, indexed by the first dimension.
y: Numpy `array` of labels, with the same first dimension as `x`.
batch_size: Number of elements in each training batch.
Returns:... | def build_input_pipeline(x, y, batch_size):
"""Build a Dataset iterator for supervised classification.
Args:
x: Numpy `array` of features, indexed by the first dimension.
y: Numpy `array` of labels, with the same first dimension as `x`.
batch_size: Number of elements in each training batch.
Returns:... | [
"Build",
"a",
"Dataset",
"iterator",
"for",
"supervised",
"classification",
"."
] | tensorflow/probability | python | https://github.com/tensorflow/probability/blob/e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5/tensorflow_probability/examples/logistic_regression.py#L134-L152 | [
"def",
"build_input_pipeline",
"(",
"x",
",",
"y",
",",
"batch_size",
")",
":",
"training_dataset",
"=",
"tf",
".",
"data",
".",
"Dataset",
".",
"from_tensor_slices",
"(",
"(",
"x",
",",
"y",
")",
")",
"training_batches",
"=",
"training_dataset",
".",
"rep... | e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5 |
test | _maybe_check_valid_map_values | Validate `map_values` if `validate_args`==True. | tensorflow_probability/python/bijectors/categorical_to_discrete.py | def _maybe_check_valid_map_values(map_values, validate_args):
"""Validate `map_values` if `validate_args`==True."""
assertions = []
message = 'Rank of map_values must be 1.'
if tensorshape_util.rank(map_values.shape) is not None:
if tensorshape_util.rank(map_values.shape) != 1:
raise ValueError(messa... | def _maybe_check_valid_map_values(map_values, validate_args):
"""Validate `map_values` if `validate_args`==True."""
assertions = []
message = 'Rank of map_values must be 1.'
if tensorshape_util.rank(map_values.shape) is not None:
if tensorshape_util.rank(map_values.shape) != 1:
raise ValueError(messa... | [
"Validate",
"map_values",
"if",
"validate_args",
"==",
"True",
"."
] | tensorflow/probability | python | https://github.com/tensorflow/probability/blob/e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5/tensorflow_probability/python/bijectors/categorical_to_discrete.py#L127-L154 | [
"def",
"_maybe_check_valid_map_values",
"(",
"map_values",
",",
"validate_args",
")",
":",
"assertions",
"=",
"[",
"]",
"message",
"=",
"'Rank of map_values must be 1.'",
"if",
"tensorshape_util",
".",
"rank",
"(",
"map_values",
".",
"shape",
")",
"is",
"not",
"No... | e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5 |
test | trace | `TransitionOperator` that runs `fn` repeatedly and traces its outputs.
Args:
state: A nest of `Tensor`s or None.
fn: A `TransitionOperator`.
num_steps: Number of steps to run the function for. Must be greater than 1.
trace_fn: Callable that the unpacked outputs of `fn` and returns a nest of
`Te... | experimental/fun_mcmc/fun_mcmc_lib.py | def trace(state: State, fn: TransitionOperator, num_steps: IntTensor,
trace_fn: Callable[[State, TensorNest], TensorNest]
) -> Tuple[State, TensorNest]:
"""`TransitionOperator` that runs `fn` repeatedly and traces its outputs.
Args:
state: A nest of `Tensor`s or None.
fn: A `TransitionOp... | def trace(state: State, fn: TransitionOperator, num_steps: IntTensor,
trace_fn: Callable[[State, TensorNest], TensorNest]
) -> Tuple[State, TensorNest]:
"""`TransitionOperator` that runs `fn` repeatedly and traces its outputs.
Args:
state: A nest of `Tensor`s or None.
fn: A `TransitionOp... | [
"TransitionOperator",
"that",
"runs",
"fn",
"repeatedly",
"and",
"traces",
"its",
"outputs",
"."
] | tensorflow/probability | python | https://github.com/tensorflow/probability/blob/e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5/experimental/fun_mcmc/fun_mcmc_lib.py#L87-L119 | [
"def",
"trace",
"(",
"state",
":",
"State",
",",
"fn",
":",
"TransitionOperator",
",",
"num_steps",
":",
"IntTensor",
",",
"trace_fn",
":",
"Callable",
"[",
"[",
"State",
",",
"TensorNest",
"]",
",",
"TensorNest",
"]",
")",
"->",
"Tuple",
"[",
"State",
... | e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5 |
test | call_fn | Calls a transition operator with args, unpacking args if its a sequence.
Args:
fn: A `TransitionOperator`.
args: Arguments to `fn`
Returns:
ret: Return value of `fn`. | experimental/fun_mcmc/fun_mcmc_lib.py | def call_fn(fn: TransitionOperator, args: Union[Tuple[Any], Any]) -> Any:
"""Calls a transition operator with args, unpacking args if its a sequence.
Args:
fn: A `TransitionOperator`.
args: Arguments to `fn`
Returns:
ret: Return value of `fn`.
"""
if isinstance(args, (list, tuple)) and not mcmc... | def call_fn(fn: TransitionOperator, args: Union[Tuple[Any], Any]) -> Any:
"""Calls a transition operator with args, unpacking args if its a sequence.
Args:
fn: A `TransitionOperator`.
args: Arguments to `fn`
Returns:
ret: Return value of `fn`.
"""
if isinstance(args, (list, tuple)) and not mcmc... | [
"Calls",
"a",
"transition",
"operator",
"with",
"args",
"unpacking",
"args",
"if",
"its",
"a",
"sequence",
"."
] | tensorflow/probability | python | https://github.com/tensorflow/probability/blob/e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5/experimental/fun_mcmc/fun_mcmc_lib.py#L122-L137 | [
"def",
"call_fn",
"(",
"fn",
":",
"TransitionOperator",
",",
"args",
":",
"Union",
"[",
"Tuple",
"[",
"Any",
"]",
",",
"Any",
"]",
")",
"->",
"Any",
":",
"if",
"isinstance",
"(",
"args",
",",
"(",
"list",
",",
"tuple",
")",
")",
"and",
"not",
"mc... | e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5 |
test | call_and_grads | Calls `fn` and returns the gradients with respect to `fn`'s first output.
Args:
fn: A `TransitionOperator`.
args: Arguments to `fn`
Returns:
ret: First output of `fn`.
extra: Second output of `fn`.
grads: Gradients of `ret` with respect to `args`. | experimental/fun_mcmc/fun_mcmc_lib.py | def call_and_grads(fn: TransitionOperator, args: Union[Tuple[Any], Any]
) -> Tuple[tf.Tensor, TensorNest, TensorNest]:
"""Calls `fn` and returns the gradients with respect to `fn`'s first output.
Args:
fn: A `TransitionOperator`.
args: Arguments to `fn`
Returns:
ret: First output o... | def call_and_grads(fn: TransitionOperator, args: Union[Tuple[Any], Any]
) -> Tuple[tf.Tensor, TensorNest, TensorNest]:
"""Calls `fn` and returns the gradients with respect to `fn`'s first output.
Args:
fn: A `TransitionOperator`.
args: Arguments to `fn`
Returns:
ret: First output o... | [
"Calls",
"fn",
"and",
"returns",
"the",
"gradients",
"with",
"respect",
"to",
"fn",
"s",
"first",
"output",
"."
] | tensorflow/probability | python | https://github.com/tensorflow/probability/blob/e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5/experimental/fun_mcmc/fun_mcmc_lib.py#L140-L157 | [
"def",
"call_and_grads",
"(",
"fn",
":",
"TransitionOperator",
",",
"args",
":",
"Union",
"[",
"Tuple",
"[",
"Any",
"]",
",",
"Any",
"]",
")",
"->",
"Tuple",
"[",
"tf",
".",
"Tensor",
",",
"TensorNest",
",",
"TensorNest",
"]",
":",
"with",
"tf",
".",... | e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5 |
test | maybe_broadcast_structure | Maybe broadcasts `from_structure` to `to_structure`.
If `from_structure` is a singleton, it is tiled to match the structure of
`to_structure`. Note that the elements in `from_structure` are not copied if
this tiling occurs.
Args:
from_structure: A structure.
to_structure: A structure.
Returns:
... | experimental/fun_mcmc/fun_mcmc_lib.py | def maybe_broadcast_structure(from_structure: Any, to_structure: Any) -> Any:
"""Maybe broadcasts `from_structure` to `to_structure`.
If `from_structure` is a singleton, it is tiled to match the structure of
`to_structure`. Note that the elements in `from_structure` are not copied if
this tiling occurs.
Arg... | def maybe_broadcast_structure(from_structure: Any, to_structure: Any) -> Any:
"""Maybe broadcasts `from_structure` to `to_structure`.
If `from_structure` is a singleton, it is tiled to match the structure of
`to_structure`. Note that the elements in `from_structure` are not copied if
this tiling occurs.
Arg... | [
"Maybe",
"broadcasts",
"from_structure",
"to",
"to_structure",
"."
] | tensorflow/probability | python | https://github.com/tensorflow/probability/blob/e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5/experimental/fun_mcmc/fun_mcmc_lib.py#L160-L178 | [
"def",
"maybe_broadcast_structure",
"(",
"from_structure",
":",
"Any",
",",
"to_structure",
":",
"Any",
")",
"->",
"Any",
":",
"flat_from",
"=",
"tf",
".",
"nest",
".",
"flatten",
"(",
"from_structure",
")",
"flat_to",
"=",
"tf",
".",
"nest",
".",
"flatten... | e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5 |
test | transform_log_prob_fn | Transforms a log-prob function using a bijector.
This takes a log-prob function and creates a new log-prob function that now
takes takes state in the domain of the bijector, forward transforms that state
and calls the original log-prob function. It then returns the log-probability
that correctly accounts for t... | experimental/fun_mcmc/fun_mcmc_lib.py | def transform_log_prob_fn(log_prob_fn: PotentialFn,
bijector: BijectorNest,
init_state: State = None
) -> Union[PotentialFn, Tuple[PotentialFn, State]]:
"""Transforms a log-prob function using a bijector.
This takes a log-prob function an... | def transform_log_prob_fn(log_prob_fn: PotentialFn,
bijector: BijectorNest,
init_state: State = None
) -> Union[PotentialFn, Tuple[PotentialFn, State]]:
"""Transforms a log-prob function using a bijector.
This takes a log-prob function an... | [
"Transforms",
"a",
"log",
"-",
"prob",
"function",
"using",
"a",
"bijector",
"."
] | tensorflow/probability | python | https://github.com/tensorflow/probability/blob/e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5/experimental/fun_mcmc/fun_mcmc_lib.py#L181-L239 | [
"def",
"transform_log_prob_fn",
"(",
"log_prob_fn",
":",
"PotentialFn",
",",
"bijector",
":",
"BijectorNest",
",",
"init_state",
":",
"State",
"=",
"None",
")",
"->",
"Union",
"[",
"PotentialFn",
",",
"Tuple",
"[",
"PotentialFn",
",",
"State",
"]",
"]",
":",... | e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5 |
test | leapfrog_step | Leapfrog `TransitionOperator`.
Args:
leapfrog_step_state: LeapFrogStepState.
step_size: Step size, structure broadcastable to the `target_log_prob_fn`
state.
target_log_prob_fn: Target log prob fn.
kinetic_energy_fn: Kinetic energy fn.
Returns:
leapfrog_step_state: LeapFrogStepState.
... | experimental/fun_mcmc/fun_mcmc_lib.py | def leapfrog_step(leapfrog_step_state: LeapFrogStepState,
step_size: FloatTensor, target_log_prob_fn: PotentialFn,
kinetic_energy_fn: PotentialFn
) -> Tuple[LeapFrogStepState, LeapFrogStepExtras]:
"""Leapfrog `TransitionOperator`.
Args:
leapfrog_step_state: ... | def leapfrog_step(leapfrog_step_state: LeapFrogStepState,
step_size: FloatTensor, target_log_prob_fn: PotentialFn,
kinetic_energy_fn: PotentialFn
) -> Tuple[LeapFrogStepState, LeapFrogStepExtras]:
"""Leapfrog `TransitionOperator`.
Args:
leapfrog_step_state: ... | [
"Leapfrog",
"TransitionOperator",
"."
] | tensorflow/probability | python | https://github.com/tensorflow/probability/blob/e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5/experimental/fun_mcmc/fun_mcmc_lib.py#L249-L296 | [
"def",
"leapfrog_step",
"(",
"leapfrog_step_state",
":",
"LeapFrogStepState",
",",
"step_size",
":",
"FloatTensor",
",",
"target_log_prob_fn",
":",
"PotentialFn",
",",
"kinetic_energy_fn",
":",
"PotentialFn",
")",
"->",
"Tuple",
"[",
"LeapFrogStepState",
",",
"LeapFro... | e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5 |
test | metropolis_hastings_step | Metropolis-Hastings step.
This probabilistically chooses between `current_state` and `proposed_state`
based on the `energy_change` so as to preserve detailed balance.
Energy change is the negative of `log_accept_ratio`.
Args:
current_state: Current state.
proposed_state: Proposed state.
energy_ch... | experimental/fun_mcmc/fun_mcmc_lib.py | def metropolis_hastings_step(current_state: State,
proposed_state: State,
energy_change: FloatTensor,
seed=None) -> Tuple[State, tf.Tensor, tf.Tensor]:
"""Metropolis-Hastings step.
This probabilistically chooses between `current... | def metropolis_hastings_step(current_state: State,
proposed_state: State,
energy_change: FloatTensor,
seed=None) -> Tuple[State, tf.Tensor, tf.Tensor]:
"""Metropolis-Hastings step.
This probabilistically chooses between `current... | [
"Metropolis",
"-",
"Hastings",
"step",
"."
] | tensorflow/probability | python | https://github.com/tensorflow/probability/blob/e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5/experimental/fun_mcmc/fun_mcmc_lib.py#L299-L345 | [
"def",
"metropolis_hastings_step",
"(",
"current_state",
":",
"State",
",",
"proposed_state",
":",
"State",
",",
"energy_change",
":",
"FloatTensor",
",",
"seed",
"=",
"None",
")",
"->",
"Tuple",
"[",
"State",
",",
"tf",
".",
"Tensor",
",",
"tf",
".",
"Ten... | e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5 |
test | hamiltonian_monte_carlo | Hamiltonian Monte Carlo `TransitionOperator`.
#### Example
```python
step_size = 0.2
num_steps = 2000
num_leapfrog_steps = 10
state = tf.ones([16, 2])
base_mean = [1., 0]
base_cov = [[1, 0.5], [0.5, 1]]
bijector = tfb.Softplus()
base_dist = tfd.MultivariateNormalFullCovariance(
loc=base_me... | experimental/fun_mcmc/fun_mcmc_lib.py | def hamiltonian_monte_carlo(
hmc_state: HamiltonianMonteCarloState,
target_log_prob_fn: PotentialFn,
step_size: Any,
num_leapfrog_steps: IntTensor,
momentum: State = None,
kinetic_energy_fn: PotentialFn = None,
momentum_sample_fn: MomentumSampleFn = None,
leapfrog_trace_fn: Callable[[Lea... | def hamiltonian_monte_carlo(
hmc_state: HamiltonianMonteCarloState,
target_log_prob_fn: PotentialFn,
step_size: Any,
num_leapfrog_steps: IntTensor,
momentum: State = None,
kinetic_energy_fn: PotentialFn = None,
momentum_sample_fn: MomentumSampleFn = None,
leapfrog_trace_fn: Callable[[Lea... | [
"Hamiltonian",
"Monte",
"Carlo",
"TransitionOperator",
"."
] | tensorflow/probability | python | https://github.com/tensorflow/probability/blob/e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5/experimental/fun_mcmc/fun_mcmc_lib.py#L361-L517 | [
"def",
"hamiltonian_monte_carlo",
"(",
"hmc_state",
":",
"HamiltonianMonteCarloState",
",",
"target_log_prob_fn",
":",
"PotentialFn",
",",
"step_size",
":",
"Any",
",",
"num_leapfrog_steps",
":",
"IntTensor",
",",
"momentum",
":",
"State",
"=",
"None",
",",
"kinetic... | e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5 |
test | sign_adaptation | A function to do simple sign-based control of a variable.
```
control = control * (1. + adaptation_rate) ** sign(output - set_point)
```
Args:
control: The control variable.
output: The output variable.
set_point: The set point for `output`. This function will adjust `control`
so that `outpu... | experimental/fun_mcmc/fun_mcmc_lib.py | def sign_adaptation(control: FloatNest,
output: FloatTensor,
set_point: FloatTensor,
adaptation_rate: FloatTensor = 0.01) -> FloatNest:
"""A function to do simple sign-based control of a variable.
```
control = control * (1. + adaptation_rate) ** sign(o... | def sign_adaptation(control: FloatNest,
output: FloatTensor,
set_point: FloatTensor,
adaptation_rate: FloatTensor = 0.01) -> FloatNest:
"""A function to do simple sign-based control of a variable.
```
control = control * (1. + adaptation_rate) ** sign(o... | [
"A",
"function",
"to",
"do",
"simple",
"sign",
"-",
"based",
"control",
"of",
"a",
"variable",
"."
] | tensorflow/probability | python | https://github.com/tensorflow/probability/blob/e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5/experimental/fun_mcmc/fun_mcmc_lib.py#L520-L550 | [
"def",
"sign_adaptation",
"(",
"control",
":",
"FloatNest",
",",
"output",
":",
"FloatTensor",
",",
"set_point",
":",
"FloatTensor",
",",
"adaptation_rate",
":",
"FloatTensor",
"=",
"0.01",
")",
"->",
"FloatNest",
":",
"def",
"_get_new_control",
"(",
"control",
... | e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5 |
test | _ConvVariational.compute_output_shape | Computes the output shape of the layer.
Args:
input_shape: Shape tuple (tuple of integers) or list of shape tuples
(one per output tensor of the layer). Shape tuples can include None for
free dimensions, instead of an integer.
Returns:
output_shape: A tuple representing the output ... | tensorflow_probability/python/layers/conv_variational.py | def compute_output_shape(self, input_shape):
"""Computes the output shape of the layer.
Args:
input_shape: Shape tuple (tuple of integers) or list of shape tuples
(one per output tensor of the layer). Shape tuples can include None for
free dimensions, instead of an integer.
Returns:
... | def compute_output_shape(self, input_shape):
"""Computes the output shape of the layer.
Args:
input_shape: Shape tuple (tuple of integers) or list of shape tuples
(one per output tensor of the layer). Shape tuples can include None for
free dimensions, instead of an integer.
Returns:
... | [
"Computes",
"the",
"output",
"shape",
"of",
"the",
"layer",
"."
] | tensorflow/probability | python | https://github.com/tensorflow/probability/blob/e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5/tensorflow_probability/python/layers/conv_variational.py#L249-L284 | [
"def",
"compute_output_shape",
"(",
"self",
",",
"input_shape",
")",
":",
"input_shape",
"=",
"tf",
".",
"TensorShape",
"(",
"input_shape",
")",
".",
"as_list",
"(",
")",
"if",
"self",
".",
"data_format",
"==",
"'channels_last'",
":",
"space",
"=",
"input_sh... | e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5 |
test | _ConvVariational.get_config | Returns the config of the layer.
A layer config is a Python dictionary (serializable) containing the
configuration of a layer. The same layer can be reinstantiated later
(without its trained weights) from this configuration.
Returns:
config: A Python dictionary of class keyword arguments and the... | tensorflow_probability/python/layers/conv_variational.py | def get_config(self):
"""Returns the config of the layer.
A layer config is a Python dictionary (serializable) containing the
configuration of a layer. The same layer can be reinstantiated later
(without its trained weights) from this configuration.
Returns:
config: A Python dictionary of cl... | def get_config(self):
"""Returns the config of the layer.
A layer config is a Python dictionary (serializable) containing the
configuration of a layer. The same layer can be reinstantiated later
(without its trained weights) from this configuration.
Returns:
config: A Python dictionary of cl... | [
"Returns",
"the",
"config",
"of",
"the",
"layer",
"."
] | tensorflow/probability | python | https://github.com/tensorflow/probability/blob/e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5/tensorflow_probability/python/layers/conv_variational.py#L286-L330 | [
"def",
"get_config",
"(",
"self",
")",
":",
"config",
"=",
"{",
"'filters'",
":",
"self",
".",
"filters",
",",
"'kernel_size'",
":",
"self",
".",
"kernel_size",
",",
"'strides'",
":",
"self",
".",
"strides",
",",
"'padding'",
":",
"self",
".",
"padding",... | e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5 |
test | _ConvVariational.from_config | Creates a layer from its config.
This method is the reverse of `get_config`, capable of instantiating the
same layer from the config dictionary.
Args:
config: A Python dictionary, typically the output of `get_config`.
Returns:
layer: A layer instance. | tensorflow_probability/python/layers/conv_variational.py | def from_config(cls, config):
"""Creates a layer from its config.
This method is the reverse of `get_config`, capable of instantiating the
same layer from the config dictionary.
Args:
config: A Python dictionary, typically the output of `get_config`.
Returns:
layer: A layer instance.
... | def from_config(cls, config):
"""Creates a layer from its config.
This method is the reverse of `get_config`, capable of instantiating the
same layer from the config dictionary.
Args:
config: A Python dictionary, typically the output of `get_config`.
Returns:
layer: A layer instance.
... | [
"Creates",
"a",
"layer",
"from",
"its",
"config",
"."
] | tensorflow/probability | python | https://github.com/tensorflow/probability/blob/e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5/tensorflow_probability/python/layers/conv_variational.py#L333-L363 | [
"def",
"from_config",
"(",
"cls",
",",
"config",
")",
":",
"config",
"=",
"config",
".",
"copy",
"(",
")",
"function_keys",
"=",
"[",
"'kernel_posterior_fn'",
",",
"'kernel_posterior_tensor_fn'",
",",
"'kernel_prior_fn'",
",",
"'kernel_divergence_fn'",
",",
"'bias... | e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5 |
test | _ConvFlipout.get_config | Returns the config of the layer.
A layer config is a Python dictionary (serializable) containing the
configuration of a layer. The same layer can be reinstantiated later
(without its trained weights) from this configuration.
Returns:
config: A Python dictionary of class keyword arguments and the... | tensorflow_probability/python/layers/conv_variational.py | def get_config(self):
"""Returns the config of the layer.
A layer config is a Python dictionary (serializable) containing the
configuration of a layer. The same layer can be reinstantiated later
(without its trained weights) from this configuration.
Returns:
config: A Python dictionary of cl... | def get_config(self):
"""Returns the config of the layer.
A layer config is a Python dictionary (serializable) containing the
configuration of a layer. The same layer can be reinstantiated later
(without its trained weights) from this configuration.
Returns:
config: A Python dictionary of cl... | [
"Returns",
"the",
"config",
"of",
"the",
"layer",
"."
] | tensorflow/probability | python | https://github.com/tensorflow/probability/blob/e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5/tensorflow_probability/python/layers/conv_variational.py#L1111-L1126 | [
"def",
"get_config",
"(",
"self",
")",
":",
"config",
"=",
"{",
"'seed'",
":",
"self",
".",
"seed",
",",
"}",
"base_config",
"=",
"super",
"(",
"_ConvFlipout",
",",
"self",
")",
".",
"get_config",
"(",
")",
"return",
"dict",
"(",
"list",
"(",
"base_c... | e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5 |
test | _as_tensor | Convenience to convert to `Tensor` or leave as `None`. | tensorflow_probability/python/bijectors/affine.py | def _as_tensor(x, name, dtype):
"""Convenience to convert to `Tensor` or leave as `None`."""
return None if x is None else tf.convert_to_tensor(
value=x, name=name, dtype=dtype) | def _as_tensor(x, name, dtype):
"""Convenience to convert to `Tensor` or leave as `None`."""
return None if x is None else tf.convert_to_tensor(
value=x, name=name, dtype=dtype) | [
"Convenience",
"to",
"convert",
"to",
"Tensor",
"or",
"leave",
"as",
"None",
"."
] | tensorflow/probability | python | https://github.com/tensorflow/probability/blob/e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5/tensorflow_probability/python/bijectors/affine.py#L34-L37 | [
"def",
"_as_tensor",
"(",
"x",
",",
"name",
",",
"dtype",
")",
":",
"return",
"None",
"if",
"x",
"is",
"None",
"else",
"tf",
".",
"convert_to_tensor",
"(",
"value",
"=",
"x",
",",
"name",
"=",
"name",
",",
"dtype",
"=",
"dtype",
")"
] | e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5 |
test | Affine._create_scale_operator | Construct `scale` from various components.
Args:
identity_multiplier: floating point rank 0 `Tensor` representing a scaling
done to the identity matrix.
diag: Floating-point `Tensor` representing the diagonal matrix.`diag` has
shape `[N1, N2, ... k]`, which represents a k x k diagonal ... | tensorflow_probability/python/bijectors/affine.py | def _create_scale_operator(self, identity_multiplier, diag, tril,
perturb_diag, perturb_factor, shift, validate_args,
dtype):
"""Construct `scale` from various components.
Args:
identity_multiplier: floating point rank 0 `Tensor` representing a sc... | def _create_scale_operator(self, identity_multiplier, diag, tril,
perturb_diag, perturb_factor, shift, validate_args,
dtype):
"""Construct `scale` from various components.
Args:
identity_multiplier: floating point rank 0 `Tensor` representing a sc... | [
"Construct",
"scale",
"from",
"various",
"components",
"."
] | tensorflow/probability | python | https://github.com/tensorflow/probability/blob/e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5/tensorflow_probability/python/bijectors/affine.py#L238-L309 | [
"def",
"_create_scale_operator",
"(",
"self",
",",
"identity_multiplier",
",",
"diag",
",",
"tril",
",",
"perturb_diag",
",",
"perturb_factor",
",",
"shift",
",",
"validate_args",
",",
"dtype",
")",
":",
"identity_multiplier",
"=",
"_as_tensor",
"(",
"identity_mul... | e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5 |
test | random_walk_normal_fn | Returns a callable that adds a random normal perturbation to the input.
This function returns a callable that accepts a Python `list` of `Tensor`s of
any shapes and `dtypes` representing the state parts of the `current_state`
and a random seed. The supplied argument `scale` must be a `Tensor` or Python
`list`... | tensorflow_probability/python/mcmc/random_walk_metropolis.py | def random_walk_normal_fn(scale=1., name=None):
"""Returns a callable that adds a random normal perturbation to the input.
This function returns a callable that accepts a Python `list` of `Tensor`s of
any shapes and `dtypes` representing the state parts of the `current_state`
and a random seed. The supplied a... | def random_walk_normal_fn(scale=1., name=None):
"""Returns a callable that adds a random normal perturbation to the input.
This function returns a callable that accepts a Python `list` of `Tensor`s of
any shapes and `dtypes` representing the state parts of the `current_state`
and a random seed. The supplied a... | [
"Returns",
"a",
"callable",
"that",
"adds",
"a",
"random",
"normal",
"perturbation",
"to",
"the",
"input",
"."
] | tensorflow/probability | python | https://github.com/tensorflow/probability/blob/e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5/tensorflow_probability/python/mcmc/random_walk_metropolis.py#L48-L109 | [
"def",
"random_walk_normal_fn",
"(",
"scale",
"=",
"1.",
",",
"name",
"=",
"None",
")",
":",
"def",
"_fn",
"(",
"state_parts",
",",
"seed",
")",
":",
"\"\"\"Adds a normal perturbation to the input state.\n\n Args:\n state_parts: A list of `Tensor`s of any shape and re... | e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5 |
test | random_walk_uniform_fn | Returns a callable that adds a random uniform perturbation to the input.
For more details on `random_walk_uniform_fn`, see
`random_walk_normal_fn`. `scale` might
be a `Tensor` or a list of `Tensor`s that should broadcast with state parts
of the `current_state`. The generated uniform perturbation is sampled as ... | tensorflow_probability/python/mcmc/random_walk_metropolis.py | def random_walk_uniform_fn(scale=1., name=None):
"""Returns a callable that adds a random uniform perturbation to the input.
For more details on `random_walk_uniform_fn`, see
`random_walk_normal_fn`. `scale` might
be a `Tensor` or a list of `Tensor`s that should broadcast with state parts
of the `current_sta... | def random_walk_uniform_fn(scale=1., name=None):
"""Returns a callable that adds a random uniform perturbation to the input.
For more details on `random_walk_uniform_fn`, see
`random_walk_normal_fn`. `scale` might
be a `Tensor` or a list of `Tensor`s that should broadcast with state parts
of the `current_sta... | [
"Returns",
"a",
"callable",
"that",
"adds",
"a",
"random",
"uniform",
"perturbation",
"to",
"the",
"input",
"."
] | tensorflow/probability | python | https://github.com/tensorflow/probability/blob/e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5/tensorflow_probability/python/mcmc/random_walk_metropolis.py#L112-L170 | [
"def",
"random_walk_uniform_fn",
"(",
"scale",
"=",
"1.",
",",
"name",
"=",
"None",
")",
":",
"def",
"_fn",
"(",
"state_parts",
",",
"seed",
")",
":",
"\"\"\"Adds a uniform perturbation to the input state.\n\n Args:\n state_parts: A list of `Tensor`s of any shape and ... | e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5 |
test | _kl_independent | Batched KL divergence `KL(a || b)` for Independent distributions.
We can leverage the fact that
```
KL(Independent(a) || Independent(b)) = sum(KL(a || b))
```
where the sum is over the `reinterpreted_batch_ndims`.
Args:
a: Instance of `Independent`.
b: Instance of `Independent`.
name: (optiona... | tensorflow_probability/python/distributions/independent.py | def _kl_independent(a, b, name="kl_independent"):
"""Batched KL divergence `KL(a || b)` for Independent distributions.
We can leverage the fact that
```
KL(Independent(a) || Independent(b)) = sum(KL(a || b))
```
where the sum is over the `reinterpreted_batch_ndims`.
Args:
a: Instance of `Independent... | def _kl_independent(a, b, name="kl_independent"):
"""Batched KL divergence `KL(a || b)` for Independent distributions.
We can leverage the fact that
```
KL(Independent(a) || Independent(b)) = sum(KL(a || b))
```
where the sum is over the `reinterpreted_batch_ndims`.
Args:
a: Instance of `Independent... | [
"Batched",
"KL",
"divergence",
"KL",
"(",
"a",
"||",
"b",
")",
"for",
"Independent",
"distributions",
"."
] | tensorflow/probability | python | https://github.com/tensorflow/probability/blob/e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5/tensorflow_probability/python/distributions/independent.py#L279-L339 | [
"def",
"_kl_independent",
"(",
"a",
",",
"b",
",",
"name",
"=",
"\"kl_independent\"",
")",
":",
"p",
"=",
"a",
".",
"distribution",
"q",
"=",
"b",
".",
"distribution",
"# The KL between any two (non)-batched distributions is a scalar.",
"# Given that the KL between two ... | e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5 |
test | Independent._get_default_reinterpreted_batch_ndims | Computes the default value for reinterpreted_batch_ndim __init__ arg. | tensorflow_probability/python/distributions/independent.py | def _get_default_reinterpreted_batch_ndims(self, distribution):
"""Computes the default value for reinterpreted_batch_ndim __init__ arg."""
ndims = prefer_static.rank_from_shape(
distribution.batch_shape_tensor, distribution.batch_shape)
return prefer_static.maximum(0, ndims - 1) | def _get_default_reinterpreted_batch_ndims(self, distribution):
"""Computes the default value for reinterpreted_batch_ndim __init__ arg."""
ndims = prefer_static.rank_from_shape(
distribution.batch_shape_tensor, distribution.batch_shape)
return prefer_static.maximum(0, ndims - 1) | [
"Computes",
"the",
"default",
"value",
"for",
"reinterpreted_batch_ndim",
"__init__",
"arg",
"."
] | tensorflow/probability | python | https://github.com/tensorflow/probability/blob/e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5/tensorflow_probability/python/distributions/independent.py#L271-L275 | [
"def",
"_get_default_reinterpreted_batch_ndims",
"(",
"self",
",",
"distribution",
")",
":",
"ndims",
"=",
"prefer_static",
".",
"rank_from_shape",
"(",
"distribution",
".",
"batch_shape_tensor",
",",
"distribution",
".",
"batch_shape",
")",
"return",
"prefer_static",
... | e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5 |
test | Mixture._expand_to_event_rank | Expand the rank of x up to static_event_rank times for broadcasting.
The static event rank was checked to not be None at construction time.
Args:
x: A tensor to expand.
Returns:
The expanded tensor. | tensorflow_probability/python/distributions/mixture.py | def _expand_to_event_rank(self, x):
"""Expand the rank of x up to static_event_rank times for broadcasting.
The static event rank was checked to not be None at construction time.
Args:
x: A tensor to expand.
Returns:
The expanded tensor.
"""
expanded_x = x
for _ in range(tensor... | def _expand_to_event_rank(self, x):
"""Expand the rank of x up to static_event_rank times for broadcasting.
The static event rank was checked to not be None at construction time.
Args:
x: A tensor to expand.
Returns:
The expanded tensor.
"""
expanded_x = x
for _ in range(tensor... | [
"Expand",
"the",
"rank",
"of",
"x",
"up",
"to",
"static_event_rank",
"times",
"for",
"broadcasting",
"."
] | tensorflow/probability | python | https://github.com/tensorflow/probability/blob/e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5/tensorflow_probability/python/distributions/mixture.py#L235-L248 | [
"def",
"_expand_to_event_rank",
"(",
"self",
",",
"x",
")",
":",
"expanded_x",
"=",
"x",
"for",
"_",
"in",
"range",
"(",
"tensorshape_util",
".",
"rank",
"(",
"self",
".",
"event_shape",
")",
")",
":",
"expanded_x",
"=",
"tf",
".",
"expand_dims",
"(",
... | e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5 |
test | Mixture.entropy_lower_bound | r"""A lower bound on the entropy of this mixture model.
The bound below is not always very tight, and its usefulness depends
on the mixture probabilities and the components in use.
A lower bound is useful for ELBO when the `Mixture` is the variational
distribution:
\\(
\log p(x) >= ELBO = \in... | tensorflow_probability/python/distributions/mixture.py | def entropy_lower_bound(self, name="entropy_lower_bound"):
r"""A lower bound on the entropy of this mixture model.
The bound below is not always very tight, and its usefulness depends
on the mixture probabilities and the components in use.
A lower bound is useful for ELBO when the `Mixture` is the var... | def entropy_lower_bound(self, name="entropy_lower_bound"):
r"""A lower bound on the entropy of this mixture model.
The bound below is not always very tight, and its usefulness depends
on the mixture probabilities and the components in use.
A lower bound is useful for ELBO when the `Mixture` is the var... | [
"r",
"A",
"lower",
"bound",
"on",
"the",
"entropy",
"of",
"this",
"mixture",
"model",
"."
] | tensorflow/probability | python | https://github.com/tensorflow/probability/blob/e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5/tensorflow_probability/python/distributions/mixture.py#L448-L495 | [
"def",
"entropy_lower_bound",
"(",
"self",
",",
"name",
"=",
"\"entropy_lower_bound\"",
")",
":",
"with",
"self",
".",
"_name_scope",
"(",
"name",
")",
":",
"with",
"tf",
".",
"control_dependencies",
"(",
"self",
".",
"_assertions",
")",
":",
"distribution_ent... | e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5 |
test | Mixture._cat_probs | Get a list of num_components batchwise probabilities. | tensorflow_probability/python/distributions/mixture.py | def _cat_probs(self, log_probs):
"""Get a list of num_components batchwise probabilities."""
which_softmax = tf.nn.log_softmax if log_probs else tf.nn.softmax
cat_probs = which_softmax(self.cat.logits)
cat_probs = tf.unstack(cat_probs, num=self.num_components, axis=-1)
return cat_probs | def _cat_probs(self, log_probs):
"""Get a list of num_components batchwise probabilities."""
which_softmax = tf.nn.log_softmax if log_probs else tf.nn.softmax
cat_probs = which_softmax(self.cat.logits)
cat_probs = tf.unstack(cat_probs, num=self.num_components, axis=-1)
return cat_probs | [
"Get",
"a",
"list",
"of",
"num_components",
"batchwise",
"probabilities",
"."
] | tensorflow/probability | python | https://github.com/tensorflow/probability/blob/e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5/tensorflow_probability/python/distributions/mixture.py#L497-L502 | [
"def",
"_cat_probs",
"(",
"self",
",",
"log_probs",
")",
":",
"which_softmax",
"=",
"tf",
".",
"nn",
".",
"log_softmax",
"if",
"log_probs",
"else",
"tf",
".",
"nn",
".",
"softmax",
"cat_probs",
"=",
"which_softmax",
"(",
"self",
".",
"cat",
".",
"logits"... | e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5 |
test | _maybe_validate_args | Validate `outcomes`, `logits` and `probs`'s shapes. | tensorflow_probability/python/distributions/finite_discrete.py | def _maybe_validate_args(outcomes, logits, probs, validate_args):
"""Validate `outcomes`, `logits` and `probs`'s shapes."""
assertions = []
def validate_equal_last_dim(tensor_a, tensor_b, message):
if tensor_a.shape.is_fully_defined() and tensor_b.shape.is_fully_defined():
if tensor_a.shape[-1] != tens... | def _maybe_validate_args(outcomes, logits, probs, validate_args):
"""Validate `outcomes`, `logits` and `probs`'s shapes."""
assertions = []
def validate_equal_last_dim(tensor_a, tensor_b, message):
if tensor_a.shape.is_fully_defined() and tensor_b.shape.is_fully_defined():
if tensor_a.shape[-1] != tens... | [
"Validate",
"outcomes",
"logits",
"and",
"probs",
"s",
"shapes",
"."
] | tensorflow/probability | python | https://github.com/tensorflow/probability/blob/e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5/tensorflow_probability/python/distributions/finite_discrete.py#L248-L297 | [
"def",
"_maybe_validate_args",
"(",
"outcomes",
",",
"logits",
",",
"probs",
",",
"validate_args",
")",
":",
"assertions",
"=",
"[",
"]",
"def",
"validate_equal_last_dim",
"(",
"tensor_a",
",",
"tensor_b",
",",
"message",
")",
":",
"if",
"tensor_a",
".",
"sh... | e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5 |
test | _ensure_tf_install | Attempt to import tensorflow, and ensure its version is sufficient.
Raises:
ImportError: if either tensorflow is not importable or its version is
inadequate. | tensorflow_probability/__init__.py | def _ensure_tf_install(): # pylint: disable=g-statement-before-imports
"""Attempt to import tensorflow, and ensure its version is sufficient.
Raises:
ImportError: if either tensorflow is not importable or its version is
inadequate.
"""
try:
import tensorflow as tf
except ImportError:
# Print... | def _ensure_tf_install(): # pylint: disable=g-statement-before-imports
"""Attempt to import tensorflow, and ensure its version is sufficient.
Raises:
ImportError: if either tensorflow is not importable or its version is
inadequate.
"""
try:
import tensorflow as tf
except ImportError:
# Print... | [
"Attempt",
"to",
"import",
"tensorflow",
"and",
"ensure",
"its",
"version",
"is",
"sufficient",
"."
] | tensorflow/probability | python | https://github.com/tensorflow/probability/blob/e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5/tensorflow_probability/__init__.py#L32-L65 | [
"def",
"_ensure_tf_install",
"(",
")",
":",
"# pylint: disable=g-statement-before-imports",
"try",
":",
"import",
"tensorflow",
"as",
"tf",
"except",
"ImportError",
":",
"# Print more informative error message, then reraise.",
"print",
"(",
"\"\\n\\nFailed to import TensorFlow. P... | e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5 |
test | logistic_regression | Bayesian logistic regression, which returns labels given features. | experimental/no_u_turn_sampler/logistic_regression.py | def logistic_regression(features):
"""Bayesian logistic regression, which returns labels given features."""
coeffs = ed.MultivariateNormalDiag(
loc=tf.zeros(features.shape[1]), name="coeffs")
labels = ed.Bernoulli(
logits=tf.tensordot(features, coeffs, [[1], [0]]), name="labels")
return labels | def logistic_regression(features):
"""Bayesian logistic regression, which returns labels given features."""
coeffs = ed.MultivariateNormalDiag(
loc=tf.zeros(features.shape[1]), name="coeffs")
labels = ed.Bernoulli(
logits=tf.tensordot(features, coeffs, [[1], [0]]), name="labels")
return labels | [
"Bayesian",
"logistic",
"regression",
"which",
"returns",
"labels",
"given",
"features",
"."
] | tensorflow/probability | python | https://github.com/tensorflow/probability/blob/e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5/experimental/no_u_turn_sampler/logistic_regression.py#L58-L64 | [
"def",
"logistic_regression",
"(",
"features",
")",
":",
"coeffs",
"=",
"ed",
".",
"MultivariateNormalDiag",
"(",
"loc",
"=",
"tf",
".",
"zeros",
"(",
"features",
".",
"shape",
"[",
"1",
"]",
")",
",",
"name",
"=",
"\"coeffs\"",
")",
"labels",
"=",
"ed... | e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5 |
test | covertype | Builds the Covertype data set. | experimental/no_u_turn_sampler/logistic_regression.py | def covertype():
"""Builds the Covertype data set."""
import sklearn.datasets # pylint: disable=g-import-not-at-top
data = sklearn.datasets.covtype.fetch_covtype()
features = data.data
labels = data.target
# Normalize features and append a column of ones for the intercept.
features -= features.mean(0)
... | def covertype():
"""Builds the Covertype data set."""
import sklearn.datasets # pylint: disable=g-import-not-at-top
data = sklearn.datasets.covtype.fetch_covtype()
features = data.data
labels = data.target
# Normalize features and append a column of ones for the intercept.
features -= features.mean(0)
... | [
"Builds",
"the",
"Covertype",
"data",
"set",
"."
] | tensorflow/probability | python | https://github.com/tensorflow/probability/blob/e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5/experimental/no_u_turn_sampler/logistic_regression.py#L67-L85 | [
"def",
"covertype",
"(",
")",
":",
"import",
"sklearn",
".",
"datasets",
"# pylint: disable=g-import-not-at-top",
"data",
"=",
"sklearn",
".",
"datasets",
".",
"covtype",
".",
"fetch_covtype",
"(",
")",
"features",
"=",
"data",
".",
"data",
"labels",
"=",
"dat... | e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5 |
test | _kl_dirichlet_dirichlet | Batchwise KL divergence KL(d1 || d2) with d1 and d2 Dirichlet.
Args:
d1: instance of a Dirichlet distribution object.
d2: instance of a Dirichlet distribution object.
name: (optional) Name to use for created operations.
default is "kl_dirichlet_dirichlet".
Returns:
Batchwise KL(d1 || d2) | tensorflow_probability/python/distributions/dirichlet.py | def _kl_dirichlet_dirichlet(d1, d2, name=None):
"""Batchwise KL divergence KL(d1 || d2) with d1 and d2 Dirichlet.
Args:
d1: instance of a Dirichlet distribution object.
d2: instance of a Dirichlet distribution object.
name: (optional) Name to use for created operations.
default is "kl_dirichlet_d... | def _kl_dirichlet_dirichlet(d1, d2, name=None):
"""Batchwise KL divergence KL(d1 || d2) with d1 and d2 Dirichlet.
Args:
d1: instance of a Dirichlet distribution object.
d2: instance of a Dirichlet distribution object.
name: (optional) Name to use for created operations.
default is "kl_dirichlet_d... | [
"Batchwise",
"KL",
"divergence",
"KL",
"(",
"d1",
"||",
"d2",
")",
"with",
"d1",
"and",
"d2",
"Dirichlet",
"."
] | tensorflow/probability | python | https://github.com/tensorflow/probability/blob/e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5/tensorflow_probability/python/distributions/dirichlet.py#L331-L403 | [
"def",
"_kl_dirichlet_dirichlet",
"(",
"d1",
",",
"d2",
",",
"name",
"=",
"None",
")",
":",
"with",
"tf",
".",
"name_scope",
"(",
"name",
"or",
"\"kl_dirichlet_dirichlet\"",
")",
":",
"# The KL between Dirichlet distributions can be derived as follows. We have",
"#",
... | e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5 |
test | Dirichlet._maybe_assert_valid_concentration | Checks the validity of the concentration parameter. | tensorflow_probability/python/distributions/dirichlet.py | def _maybe_assert_valid_concentration(self, concentration, validate_args):
"""Checks the validity of the concentration parameter."""
if not validate_args:
return concentration
return distribution_util.with_dependencies([
assert_util.assert_positive(
concentration, message="Concentr... | def _maybe_assert_valid_concentration(self, concentration, validate_args):
"""Checks the validity of the concentration parameter."""
if not validate_args:
return concentration
return distribution_util.with_dependencies([
assert_util.assert_positive(
concentration, message="Concentr... | [
"Checks",
"the",
"validity",
"of",
"the",
"concentration",
"parameter",
"."
] | tensorflow/probability | python | https://github.com/tensorflow/probability/blob/e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5/tensorflow_probability/python/distributions/dirichlet.py#L300-L315 | [
"def",
"_maybe_assert_valid_concentration",
"(",
"self",
",",
"concentration",
",",
"validate_args",
")",
":",
"if",
"not",
"validate_args",
":",
"return",
"concentration",
"return",
"distribution_util",
".",
"with_dependencies",
"(",
"[",
"assert_util",
".",
"assert_... | e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5 |
test | Dirichlet._maybe_assert_valid_sample | Checks the validity of a sample. | tensorflow_probability/python/distributions/dirichlet.py | def _maybe_assert_valid_sample(self, x):
"""Checks the validity of a sample."""
if not self.validate_args:
return x
return distribution_util.with_dependencies([
assert_util.assert_positive(x, message="samples must be positive"),
assert_util.assert_near(
tf.ones([], dtype=se... | def _maybe_assert_valid_sample(self, x):
"""Checks the validity of a sample."""
if not self.validate_args:
return x
return distribution_util.with_dependencies([
assert_util.assert_positive(x, message="samples must be positive"),
assert_util.assert_near(
tf.ones([], dtype=se... | [
"Checks",
"the",
"validity",
"of",
"a",
"sample",
"."
] | tensorflow/probability | python | https://github.com/tensorflow/probability/blob/e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5/tensorflow_probability/python/distributions/dirichlet.py#L317-L327 | [
"def",
"_maybe_assert_valid_sample",
"(",
"self",
",",
"x",
")",
":",
"if",
"not",
"self",
".",
"validate_args",
":",
"return",
"x",
"return",
"distribution_util",
".",
"with_dependencies",
"(",
"[",
"assert_util",
".",
"assert_positive",
"(",
"x",
",",
"messa... | e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5 |
test | auto_correlation | Auto correlation along one axis.
Given a `1-D` wide sense stationary (WSS) sequence `X`, the auto correlation
`RXX` may be defined as (with `E` expectation and `Conj` complex conjugate)
```
RXX[m] := E{ W[m] Conj(W[0]) } = E{ W[0] Conj(W[-m]) },
W[n] := (X[n] - MU) / S,
MU := E{ X[0] },
S**2 :=... | tensorflow_probability/python/stats/sample_stats.py | def auto_correlation(x,
axis=-1,
max_lags=None,
center=True,
normalize=True,
name='auto_correlation'):
"""Auto correlation along one axis.
Given a `1-D` wide sense stationary (WSS) sequence `X`, the auto correl... | def auto_correlation(x,
axis=-1,
max_lags=None,
center=True,
normalize=True,
name='auto_correlation'):
"""Auto correlation along one axis.
Given a `1-D` wide sense stationary (WSS) sequence `X`, the auto correl... | [
"Auto",
"correlation",
"along",
"one",
"axis",
"."
] | tensorflow/probability | python | https://github.com/tensorflow/probability/blob/e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5/tensorflow_probability/python/stats/sample_stats.py#L39-L209 | [
"def",
"auto_correlation",
"(",
"x",
",",
"axis",
"=",
"-",
"1",
",",
"max_lags",
"=",
"None",
",",
"center",
"=",
"True",
",",
"normalize",
"=",
"True",
",",
"name",
"=",
"'auto_correlation'",
")",
":",
"# Implementation details:",
"# Extend length N / 2 1-D ... | e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5 |
test | cholesky_covariance | Cholesky factor of the covariance matrix of vector-variate random samples.
This function can be use to fit a multivariate normal to data.
```python
tf.enable_eager_execution()
import tensorflow_probability as tfp
tfd = tfp.distributions
# Assume data.shape = (1000, 2). 1000 samples of a random variable ... | tensorflow_probability/python/stats/sample_stats.py | def cholesky_covariance(x, sample_axis=0, keepdims=False, name=None):
"""Cholesky factor of the covariance matrix of vector-variate random samples.
This function can be use to fit a multivariate normal to data.
```python
tf.enable_eager_execution()
import tensorflow_probability as tfp
tfd = tfp.distributi... | def cholesky_covariance(x, sample_axis=0, keepdims=False, name=None):
"""Cholesky factor of the covariance matrix of vector-variate random samples.
This function can be use to fit a multivariate normal to data.
```python
tf.enable_eager_execution()
import tensorflow_probability as tfp
tfd = tfp.distributi... | [
"Cholesky",
"factor",
"of",
"the",
"covariance",
"matrix",
"of",
"vector",
"-",
"variate",
"random",
"samples",
"."
] | tensorflow/probability | python | https://github.com/tensorflow/probability/blob/e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5/tensorflow_probability/python/stats/sample_stats.py#L212-L281 | [
"def",
"cholesky_covariance",
"(",
"x",
",",
"sample_axis",
"=",
"0",
",",
"keepdims",
"=",
"False",
",",
"name",
"=",
"None",
")",
":",
"with",
"tf",
".",
"compat",
".",
"v1",
".",
"name_scope",
"(",
"name",
",",
"'cholesky_covariance'",
",",
"values",
... | e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5 |
test | covariance | Sample covariance between observations indexed by `event_axis`.
Given `N` samples of scalar random variables `X` and `Y`, covariance may be
estimated as
```none
Cov[X, Y] := N^{-1} sum_{n=1}^N (X_n - Xbar) Conj{(Y_n - Ybar)}
Xbar := N^{-1} sum_{n=1}^N X_n
Ybar := N^{-1} sum_{n=1}^N Y_n
```
For vector... | tensorflow_probability/python/stats/sample_stats.py | def covariance(x,
y=None,
sample_axis=0,
event_axis=-1,
keepdims=False,
name=None):
"""Sample covariance between observations indexed by `event_axis`.
Given `N` samples of scalar random variables `X` and `Y`, covariance may be
estimated a... | def covariance(x,
y=None,
sample_axis=0,
event_axis=-1,
keepdims=False,
name=None):
"""Sample covariance between observations indexed by `event_axis`.
Given `N` samples of scalar random variables `X` and `Y`, covariance may be
estimated a... | [
"Sample",
"covariance",
"between",
"observations",
"indexed",
"by",
"event_axis",
"."
] | tensorflow/probability | python | https://github.com/tensorflow/probability/blob/e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5/tensorflow_probability/python/stats/sample_stats.py#L284-L462 | [
"def",
"covariance",
"(",
"x",
",",
"y",
"=",
"None",
",",
"sample_axis",
"=",
"0",
",",
"event_axis",
"=",
"-",
"1",
",",
"keepdims",
"=",
"False",
",",
"name",
"=",
"None",
")",
":",
"with",
"tf",
".",
"compat",
".",
"v1",
".",
"name_scope",
"(... | e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5 |
test | correlation | Sample correlation (Pearson) between observations indexed by `event_axis`.
Given `N` samples of scalar random variables `X` and `Y`, correlation may be
estimated as
```none
Corr[X, Y] := Cov[X, Y] / Sqrt(Cov[X, X] * Cov[Y, Y]),
where
Cov[X, Y] := N^{-1} sum_{n=1}^N (X_n - Xbar) Conj{(Y_n - Ybar)}
Xbar :... | tensorflow_probability/python/stats/sample_stats.py | def correlation(x,
y=None,
sample_axis=0,
event_axis=-1,
keepdims=False,
name=None):
"""Sample correlation (Pearson) between observations indexed by `event_axis`.
Given `N` samples of scalar random variables `X` and `Y`, correlation ma... | def correlation(x,
y=None,
sample_axis=0,
event_axis=-1,
keepdims=False,
name=None):
"""Sample correlation (Pearson) between observations indexed by `event_axis`.
Given `N` samples of scalar random variables `X` and `Y`, correlation ma... | [
"Sample",
"correlation",
"(",
"Pearson",
")",
"between",
"observations",
"indexed",
"by",
"event_axis",
"."
] | tensorflow/probability | python | https://github.com/tensorflow/probability/blob/e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5/tensorflow_probability/python/stats/sample_stats.py#L465-L549 | [
"def",
"correlation",
"(",
"x",
",",
"y",
"=",
"None",
",",
"sample_axis",
"=",
"0",
",",
"event_axis",
"=",
"-",
"1",
",",
"keepdims",
"=",
"False",
",",
"name",
"=",
"None",
")",
":",
"with",
"tf",
".",
"compat",
".",
"v1",
".",
"name_scope",
"... | e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5 |
test | stddev | Estimate standard deviation using samples.
Given `N` samples of scalar valued random variable `X`, standard deviation may
be estimated as
```none
Stddev[X] := Sqrt[Var[X]],
Var[X] := N^{-1} sum_{n=1}^N (X_n - Xbar) Conj{(X_n - Xbar)},
Xbar := N^{-1} sum_{n=1}^N X_n
```
```python
x = tf.random_norma... | tensorflow_probability/python/stats/sample_stats.py | def stddev(x, sample_axis=0, keepdims=False, name=None):
"""Estimate standard deviation using samples.
Given `N` samples of scalar valued random variable `X`, standard deviation may
be estimated as
```none
Stddev[X] := Sqrt[Var[X]],
Var[X] := N^{-1} sum_{n=1}^N (X_n - Xbar) Conj{(X_n - Xbar)},
Xbar := N... | def stddev(x, sample_axis=0, keepdims=False, name=None):
"""Estimate standard deviation using samples.
Given `N` samples of scalar valued random variable `X`, standard deviation may
be estimated as
```none
Stddev[X] := Sqrt[Var[X]],
Var[X] := N^{-1} sum_{n=1}^N (X_n - Xbar) Conj{(X_n - Xbar)},
Xbar := N... | [
"Estimate",
"standard",
"deviation",
"using",
"samples",
"."
] | tensorflow/probability | python | https://github.com/tensorflow/probability/blob/e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5/tensorflow_probability/python/stats/sample_stats.py#L552-L599 | [
"def",
"stddev",
"(",
"x",
",",
"sample_axis",
"=",
"0",
",",
"keepdims",
"=",
"False",
",",
"name",
"=",
"None",
")",
":",
"with",
"tf",
".",
"compat",
".",
"v1",
".",
"name_scope",
"(",
"name",
",",
"'stddev'",
",",
"values",
"=",
"[",
"x",
","... | e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5 |
test | variance | Estimate variance using samples.
Given `N` samples of scalar valued random variable `X`, variance may
be estimated as
```none
Var[X] := N^{-1} sum_{n=1}^N (X_n - Xbar) Conj{(X_n - Xbar)}
Xbar := N^{-1} sum_{n=1}^N X_n
```
```python
x = tf.random_normal(shape=(100, 2, 3))
# var[i, j] is the sample ... | tensorflow_probability/python/stats/sample_stats.py | def variance(x, sample_axis=0, keepdims=False, name=None):
"""Estimate variance using samples.
Given `N` samples of scalar valued random variable `X`, variance may
be estimated as
```none
Var[X] := N^{-1} sum_{n=1}^N (X_n - Xbar) Conj{(X_n - Xbar)}
Xbar := N^{-1} sum_{n=1}^N X_n
```
```python
x = t... | def variance(x, sample_axis=0, keepdims=False, name=None):
"""Estimate variance using samples.
Given `N` samples of scalar valued random variable `X`, variance may
be estimated as
```none
Var[X] := N^{-1} sum_{n=1}^N (X_n - Xbar) Conj{(X_n - Xbar)}
Xbar := N^{-1} sum_{n=1}^N X_n
```
```python
x = t... | [
"Estimate",
"variance",
"using",
"samples",
"."
] | tensorflow/probability | python | https://github.com/tensorflow/probability/blob/e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5/tensorflow_probability/python/stats/sample_stats.py#L602-L638 | [
"def",
"variance",
"(",
"x",
",",
"sample_axis",
"=",
"0",
",",
"keepdims",
"=",
"False",
",",
"name",
"=",
"None",
")",
":",
"with",
"tf",
".",
"compat",
".",
"v1",
".",
"name_scope",
"(",
"name",
",",
"'variance'",
",",
"values",
"=",
"[",
"x",
... | e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5 |
test | _make_list_or_1d_tensor | Return a list (preferred) or 1d Tensor from values, if values.ndims < 2. | tensorflow_probability/python/stats/sample_stats.py | def _make_list_or_1d_tensor(values):
"""Return a list (preferred) or 1d Tensor from values, if values.ndims < 2."""
values = tf.convert_to_tensor(value=values, name='values')
values_ = tf.get_static_value(values)
# Static didn't work.
if values_ is None:
# Cheap way to bring to at least 1d.
return va... | def _make_list_or_1d_tensor(values):
"""Return a list (preferred) or 1d Tensor from values, if values.ndims < 2."""
values = tf.convert_to_tensor(value=values, name='values')
values_ = tf.get_static_value(values)
# Static didn't work.
if values_ is None:
# Cheap way to bring to at least 1d.
return va... | [
"Return",
"a",
"list",
"(",
"preferred",
")",
"or",
"1d",
"Tensor",
"from",
"values",
"if",
"values",
".",
"ndims",
"<",
"2",
"."
] | tensorflow/probability | python | https://github.com/tensorflow/probability/blob/e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5/tensorflow_probability/python/stats/sample_stats.py#L646-L661 | [
"def",
"_make_list_or_1d_tensor",
"(",
"values",
")",
":",
"values",
"=",
"tf",
".",
"convert_to_tensor",
"(",
"value",
"=",
"values",
",",
"name",
"=",
"'values'",
")",
"values_",
"=",
"tf",
".",
"get_static_value",
"(",
"values",
")",
"# Static didn't work."... | e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5 |
test | _make_positive_axis | Rectify possibly negatively axis. Prefer return Python list. | tensorflow_probability/python/stats/sample_stats.py | def _make_positive_axis(axis, ndims):
"""Rectify possibly negatively axis. Prefer return Python list."""
axis = _make_list_or_1d_tensor(axis)
ndims = tf.convert_to_tensor(value=ndims, name='ndims', dtype=tf.int32)
ndims_ = tf.get_static_value(ndims)
if _is_list_like(axis) and ndims_ is not None:
# Stati... | def _make_positive_axis(axis, ndims):
"""Rectify possibly negatively axis. Prefer return Python list."""
axis = _make_list_or_1d_tensor(axis)
ndims = tf.convert_to_tensor(value=ndims, name='ndims', dtype=tf.int32)
ndims_ = tf.get_static_value(ndims)
if _is_list_like(axis) and ndims_ is not None:
# Stati... | [
"Rectify",
"possibly",
"negatively",
"axis",
".",
"Prefer",
"return",
"Python",
"list",
"."
] | tensorflow/probability | python | https://github.com/tensorflow/probability/blob/e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5/tensorflow_probability/python/stats/sample_stats.py#L664-L683 | [
"def",
"_make_positive_axis",
"(",
"axis",
",",
"ndims",
")",
":",
"axis",
"=",
"_make_list_or_1d_tensor",
"(",
"axis",
")",
"ndims",
"=",
"tf",
".",
"convert_to_tensor",
"(",
"value",
"=",
"ndims",
",",
"name",
"=",
"'ndims'",
",",
"dtype",
"=",
"tf",
"... | e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5 |
test | _squeeze | A version of squeeze that works with dynamic axis. | tensorflow_probability/python/stats/sample_stats.py | def _squeeze(x, axis):
"""A version of squeeze that works with dynamic axis."""
x = tf.convert_to_tensor(value=x, name='x')
if axis is None:
return tf.squeeze(x, axis=None)
axis = tf.convert_to_tensor(value=axis, name='axis', dtype=tf.int32)
axis += tf.zeros([1], dtype=axis.dtype) # Make axis at least 1d... | def _squeeze(x, axis):
"""A version of squeeze that works with dynamic axis."""
x = tf.convert_to_tensor(value=x, name='x')
if axis is None:
return tf.squeeze(x, axis=None)
axis = tf.convert_to_tensor(value=axis, name='axis', dtype=tf.int32)
axis += tf.zeros([1], dtype=axis.dtype) # Make axis at least 1d... | [
"A",
"version",
"of",
"squeeze",
"that",
"works",
"with",
"dynamic",
"axis",
"."
] | tensorflow/probability | python | https://github.com/tensorflow/probability/blob/e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5/tensorflow_probability/python/stats/sample_stats.py#L686-L694 | [
"def",
"_squeeze",
"(",
"x",
",",
"axis",
")",
":",
"x",
"=",
"tf",
".",
"convert_to_tensor",
"(",
"value",
"=",
"x",
",",
"name",
"=",
"'x'",
")",
"if",
"axis",
"is",
"None",
":",
"return",
"tf",
".",
"squeeze",
"(",
"x",
",",
"axis",
"=",
"No... | e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5 |
test | _kl_normal_normal | Calculate the batched KL divergence KL(n_a || n_b) with n_a and n_b Normal.
Args:
n_a: instance of a Normal distribution object.
n_b: instance of a Normal distribution object.
name: (optional) Name to use for created operations.
default is "kl_normal_normal".
Returns:
Batchwise KL(n_a || n_b... | tensorflow_probability/python/distributions/normal.py | def _kl_normal_normal(n_a, n_b, name=None):
"""Calculate the batched KL divergence KL(n_a || n_b) with n_a and n_b Normal.
Args:
n_a: instance of a Normal distribution object.
n_b: instance of a Normal distribution object.
name: (optional) Name to use for created operations.
default is "kl_normal... | def _kl_normal_normal(n_a, n_b, name=None):
"""Calculate the batched KL divergence KL(n_a || n_b) with n_a and n_b Normal.
Args:
n_a: instance of a Normal distribution object.
n_b: instance of a Normal distribution object.
name: (optional) Name to use for created operations.
default is "kl_normal... | [
"Calculate",
"the",
"batched",
"KL",
"divergence",
"KL",
"(",
"n_a",
"||",
"n_b",
")",
"with",
"n_a",
"and",
"n_b",
"Normal",
"."
] | tensorflow/probability | python | https://github.com/tensorflow/probability/blob/e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5/tensorflow_probability/python/distributions/normal.py#L241-L261 | [
"def",
"_kl_normal_normal",
"(",
"n_a",
",",
"n_b",
",",
"name",
"=",
"None",
")",
":",
"with",
"tf",
".",
"name_scope",
"(",
"name",
"or",
"\"kl_normal_normal\"",
")",
":",
"one",
"=",
"tf",
".",
"constant",
"(",
"1",
",",
"dtype",
"=",
"n_a",
".",
... | e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5 |
test | Normal._z | Standardize input `x` to a unit normal. | tensorflow_probability/python/distributions/normal.py | def _z(self, x):
"""Standardize input `x` to a unit normal."""
with tf.name_scope("standardize"):
return (x - self.loc) / self.scale | def _z(self, x):
"""Standardize input `x` to a unit normal."""
with tf.name_scope("standardize"):
return (x - self.loc) / self.scale | [
"Standardize",
"input",
"x",
"to",
"a",
"unit",
"normal",
"."
] | tensorflow/probability | python | https://github.com/tensorflow/probability/blob/e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5/tensorflow_probability/python/distributions/normal.py#L229-L232 | [
"def",
"_z",
"(",
"self",
",",
"x",
")",
":",
"with",
"tf",
".",
"name_scope",
"(",
"\"standardize\"",
")",
":",
"return",
"(",
"x",
"-",
"self",
".",
"loc",
")",
"/",
"self",
".",
"scale"
] | e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5 |
test | Normal._inv_z | Reconstruct input `x` from a its normalized version. | tensorflow_probability/python/distributions/normal.py | def _inv_z(self, z):
"""Reconstruct input `x` from a its normalized version."""
with tf.name_scope("reconstruct"):
return z * self.scale + self.loc | def _inv_z(self, z):
"""Reconstruct input `x` from a its normalized version."""
with tf.name_scope("reconstruct"):
return z * self.scale + self.loc | [
"Reconstruct",
"input",
"x",
"from",
"a",
"its",
"normalized",
"version",
"."
] | tensorflow/probability | python | https://github.com/tensorflow/probability/blob/e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5/tensorflow_probability/python/distributions/normal.py#L234-L237 | [
"def",
"_inv_z",
"(",
"self",
",",
"z",
")",
":",
"with",
"tf",
".",
"name_scope",
"(",
"\"reconstruct\"",
")",
":",
"return",
"z",
"*",
"self",
".",
"scale",
"+",
"self",
".",
"loc"
] | e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5 |
test | semilocal_linear_trend_transition_matrix | Build the transition matrix for a semi-local linear trend model. | tensorflow_probability/python/sts/semilocal_linear_trend.py | def semilocal_linear_trend_transition_matrix(autoregressive_coef):
"""Build the transition matrix for a semi-local linear trend model."""
# We want to write the following 2 x 2 matrix:
# [[1., 1., ], # level(t+1) = level(t) + slope(t)
# [0., ar_coef], # slope(t+1) = ar_coef * slope(t)
# but it's slightl... | def semilocal_linear_trend_transition_matrix(autoregressive_coef):
"""Build the transition matrix for a semi-local linear trend model."""
# We want to write the following 2 x 2 matrix:
# [[1., 1., ], # level(t+1) = level(t) + slope(t)
# [0., ar_coef], # slope(t+1) = ar_coef * slope(t)
# but it's slightl... | [
"Build",
"the",
"transition",
"matrix",
"for",
"a",
"semi",
"-",
"local",
"linear",
"trend",
"model",
"."
] | tensorflow/probability | python | https://github.com/tensorflow/probability/blob/e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5/tensorflow_probability/python/sts/semilocal_linear_trend.py#L241-L263 | [
"def",
"semilocal_linear_trend_transition_matrix",
"(",
"autoregressive_coef",
")",
":",
"# We want to write the following 2 x 2 matrix:",
"# [[1., 1., ], # level(t+1) = level(t) + slope(t)",
"# [0., ar_coef], # slope(t+1) = ar_coef * slope(t)",
"# but it's slightly tricky to properly incorp... | e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5 |
test | semilocal_linear_trend_transition_noise | Build the transition noise model for a semi-local linear trend model. | tensorflow_probability/python/sts/semilocal_linear_trend.py | def semilocal_linear_trend_transition_noise(level_scale,
slope_mean,
slope_scale,
autoregressive_coef):
"""Build the transition noise model for a semi-local linear trend model."""
# A... | def semilocal_linear_trend_transition_noise(level_scale,
slope_mean,
slope_scale,
autoregressive_coef):
"""Build the transition noise model for a semi-local linear trend model."""
# A... | [
"Build",
"the",
"transition",
"noise",
"model",
"for",
"a",
"semi",
"-",
"local",
"linear",
"trend",
"model",
"."
] | tensorflow/probability | python | https://github.com/tensorflow/probability/blob/e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5/tensorflow_probability/python/sts/semilocal_linear_trend.py#L266-L296 | [
"def",
"semilocal_linear_trend_transition_noise",
"(",
"level_scale",
",",
"slope_mean",
",",
"slope_scale",
",",
"autoregressive_coef",
")",
":",
"# At each timestep, the stochasticity of `level` and `slope` are given",
"# by `level_scale` and `slope_scale` respectively.",
"broadcast_ba... | e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5 |
test | sample_halton_sequence | r"""Returns a sample from the `dim` dimensional Halton sequence.
Warning: The sequence elements take values only between 0 and 1. Care must be
taken to appropriately transform the domain of a function if it differs from
the unit cube before evaluating integrals using Halton samples. It is also
important to rem... | tensorflow_probability/python/mcmc/sample_halton_sequence.py | def sample_halton_sequence(dim,
num_results=None,
sequence_indices=None,
dtype=tf.float32,
randomized=True,
seed=None,
name=None):
r"""Returns a sample from... | def sample_halton_sequence(dim,
num_results=None,
sequence_indices=None,
dtype=tf.float32,
randomized=True,
seed=None,
name=None):
r"""Returns a sample from... | [
"r",
"Returns",
"a",
"sample",
"from",
"the",
"dim",
"dimensional",
"Halton",
"sequence",
"."
] | tensorflow/probability | python | https://github.com/tensorflow/probability/blob/e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5/tensorflow_probability/python/mcmc/sample_halton_sequence.py#L39-L249 | [
"def",
"sample_halton_sequence",
"(",
"dim",
",",
"num_results",
"=",
"None",
",",
"sequence_indices",
"=",
"None",
",",
"dtype",
"=",
"tf",
".",
"float32",
",",
"randomized",
"=",
"True",
",",
"seed",
"=",
"None",
",",
"name",
"=",
"None",
")",
":",
"... | e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5 |
test | _randomize | Applies the Owen (2017) randomization to the coefficients. | tensorflow_probability/python/mcmc/sample_halton_sequence.py | def _randomize(coeffs, radixes, seed=None):
"""Applies the Owen (2017) randomization to the coefficients."""
given_dtype = coeffs.dtype
coeffs = tf.cast(coeffs, dtype=tf.int32)
num_coeffs = tf.shape(input=coeffs)[-1]
radixes = tf.reshape(tf.cast(radixes, dtype=tf.int32), shape=[-1])
stream = distributions.S... | def _randomize(coeffs, radixes, seed=None):
"""Applies the Owen (2017) randomization to the coefficients."""
given_dtype = coeffs.dtype
coeffs = tf.cast(coeffs, dtype=tf.int32)
num_coeffs = tf.shape(input=coeffs)[-1]
radixes = tf.reshape(tf.cast(radixes, dtype=tf.int32), shape=[-1])
stream = distributions.S... | [
"Applies",
"the",
"Owen",
"(",
"2017",
")",
"randomization",
"to",
"the",
"coefficients",
"."
] | tensorflow/probability | python | https://github.com/tensorflow/probability/blob/e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5/tensorflow_probability/python/mcmc/sample_halton_sequence.py#L252-L266 | [
"def",
"_randomize",
"(",
"coeffs",
",",
"radixes",
",",
"seed",
"=",
"None",
")",
":",
"given_dtype",
"=",
"coeffs",
".",
"dtype",
"coeffs",
"=",
"tf",
".",
"cast",
"(",
"coeffs",
",",
"dtype",
"=",
"tf",
".",
"int32",
")",
"num_coeffs",
"=",
"tf",
... | e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5 |
test | _get_permutations | Uniform iid sample from the space of permutations.
Draws a sample of size `num_results` from the group of permutations of degrees
specified by the `dims` tensor. These are packed together into one tensor
such that each row is one sample from each of the dimensions in `dims`. For
example, if dims = [2,3] and nu... | tensorflow_probability/python/mcmc/sample_halton_sequence.py | def _get_permutations(num_results, dims, seed=None):
"""Uniform iid sample from the space of permutations.
Draws a sample of size `num_results` from the group of permutations of degrees
specified by the `dims` tensor. These are packed together into one tensor
such that each row is one sample from each of the d... | def _get_permutations(num_results, dims, seed=None):
"""Uniform iid sample from the space of permutations.
Draws a sample of size `num_results` from the group of permutations of degrees
specified by the `dims` tensor. These are packed together into one tensor
such that each row is one sample from each of the d... | [
"Uniform",
"iid",
"sample",
"from",
"the",
"space",
"of",
"permutations",
"."
] | tensorflow/probability | python | https://github.com/tensorflow/probability/blob/e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5/tensorflow_probability/python/mcmc/sample_halton_sequence.py#L269-L301 | [
"def",
"_get_permutations",
"(",
"num_results",
",",
"dims",
",",
"seed",
"=",
"None",
")",
":",
"sample_range",
"=",
"tf",
".",
"range",
"(",
"num_results",
")",
"stream",
"=",
"distributions",
".",
"SeedStream",
"(",
"seed",
",",
"salt",
"=",
"'MCMCSampl... | e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.