本文整理汇总了Python中tensorflow.python.ops.check_ops.assert_positive函数的典型用法代码示例。如果您正苦于以下问题:Python assert_positive函数的具体用法?Python assert_positive怎么用?Python assert_positive使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了assert_positive函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: __init__
def __init__(self, alpha, beta, name="Gamma"):
"""Construct Gamma distributions with parameters `alpha` and `beta`.
The parameters `alpha` and `beta` must be shaped in a way that supports
broadcasting (e.g. `alpha + beta` is a valid operation).
Args:
alpha: `float` or `double` tensor, the shape params of the
distribution(s).
alpha must contain only positive values.
beta: `float` or `double` tensor, the inverse scale params of the
distribution(s).
beta must contain only positive values.
name: The name to prepend to all ops created by this distribution.
Raises:
TypeError: if `alpha` and `beta` are different dtypes.
"""
with ops.op_scope([alpha, beta], name):
with ops.control_dependencies([
check_ops.assert_positive(alpha), check_ops.assert_positive(beta)]):
alpha = array_ops.identity(alpha, name="alpha")
beta = array_ops.identity(beta, name="beta")
contrib_tensor_util.assert_same_float_dtype((alpha, beta))
self._broadcast_tensor = alpha + beta
self._get_batch_shape = self._broadcast_tensor.get_shape()
self._get_event_shape = tensor_shape.TensorShape([])
self._alpha = alpha
self._beta = beta
self._name = name
开发者ID:0ruben,项目名称:tensorflow,代码行数:33,代码来源:gamma.py
示例2: __init__
def __init__(self, df, mu, sigma, name="StudentT"):
"""Construct Student's t distributions.
The distributions have degree of freedom `df`, mean `mu`, and scale `sigma`.
The parameters `df`, `mu`, and `sigma` must be shaped in a way that supports
broadcasting (e.g. `df + mu + sigma` is a valid operation).
Args:
df: `float` or `double` tensor, the degrees of freedom of the
distribution(s). `df` must contain only positive values.
mu: `float` or `double` tensor, the means of the distribution(s).
sigma: `float` or `double` tensor, the scaling factor for the
distribution(s). `sigma` must contain only positive values.
Note that `sigma` is not the standard deviation of this distribution.
name: The name to give Ops created by the initializer.
Raises:
TypeError: if mu and sigma are different dtypes.
"""
super(StudentT, self).__init__()
with ops.op_scope([df, mu, sigma], name) as scope:
with ops.control_dependencies([check_ops.assert_positive(df),
check_ops.assert_positive(sigma)]):
self._df = ops.convert_to_tensor(df, name="df")
self._mu = ops.convert_to_tensor(mu, name="mu")
self._sigma = ops.convert_to_tensor(sigma, name="sigma")
contrib_tensor_util.assert_same_float_dtype(
(self._df, self._mu, self._sigma))
self._name = scope
self._get_batch_shape = self._ones().get_shape()
self._get_event_shape = tensor_shape.TensorShape([])
开发者ID:0ruben,项目名称:tensorflow,代码行数:32,代码来源:student_t.py
示例3: __init__
def __init__(self,
df,
mu,
sigma,
validate_args=False,
allow_nan_stats=True,
name="StudentT"):
"""Construct Student's t distributions.
The distributions have degree of freedom `df`, mean `mu`, and scale `sigma`.
The parameters `df`, `mu`, and `sigma` must be shaped in a way that supports
broadcasting (e.g. `df + mu + sigma` is a valid operation).
Args:
df: Floating point tensor, the degrees of freedom of the
distribution(s). `df` must contain only positive values.
mu: Floating point tensor, the means of the distribution(s).
sigma: Floating point tensor, the scaling factor for the
distribution(s). `sigma` must contain only positive values.
Note that `sigma` is not the standard deviation of this distribution.
validate_args: `Boolean`, default `False`. Whether to assert that
`df > 0` and `sigma > 0`. If `validate_args` is `False` and inputs are
invalid, correct behavior is not guaranteed.
allow_nan_stats: `Boolean`, default `True`. If `False`, raise an
exception if a statistic (e.g. mean/mode/etc...) is undefined for any
batch member. If `True`, batch members with valid parameters leading to
undefined statistics will return NaN for this statistic.
name: The name to give Ops created by the initializer.
Raises:
TypeError: if mu and sigma are different dtypes.
"""
parameters = locals()
parameters.pop("self")
with ops.name_scope(name, values=[df, mu, sigma]) as ns:
with ops.control_dependencies([
check_ops.assert_positive(df),
check_ops.assert_positive(sigma),
] if validate_args else []):
self._df = array_ops.identity(df, name="df")
self._mu = array_ops.identity(mu, name="mu")
self._sigma = array_ops.identity(sigma, name="sigma")
contrib_tensor_util.assert_same_float_dtype(
(self._df, self._mu, self._sigma))
super(StudentT, self).__init__(
dtype=self._sigma.dtype,
is_continuous=True,
is_reparameterized=True,
validate_args=validate_args,
allow_nan_stats=allow_nan_stats,
parameters=parameters,
graph_parents=[self._df, self._mu, self._sigma],
name=ns)
开发者ID:moolighty,项目名称:tensorflow,代码行数:54,代码来源:student_t.py
示例4: __init__
def __init__(self, a, b, validate_args=False, allow_nan_stats=True,
name="Beta"):
"""Initialize a batch of Beta distributions.
Args:
a: Positive floating point tensor with shape broadcastable to
`[N1,..., Nm]` `m >= 0`. Defines this as a batch of `N1 x ... x Nm`
different Beta distributions. This also defines the
dtype of the distribution.
b: Positive floating point tensor with shape broadcastable to
`[N1,..., Nm]` `m >= 0`. Defines this as a batch of `N1 x ... x Nm`
different Beta distributions.
validate_args: `Boolean`, default `False`. Whether to assert valid
values for parameters `a`, `b`, and `x` in `prob` and `log_prob`.
If `False` and inputs are invalid, correct behavior is not guaranteed.
allow_nan_stats: `Boolean`, default `True`. If `False`, raise an
exception if a statistic (e.g. mean/mode/etc...) is undefined for any
batch member. If `True`, batch members with valid parameters leading to
undefined statistics will return NaN for this statistic.
name: The name to prefix Ops created by this distribution class.
Examples:
```python
# Define 1-batch.
dist = Beta(1.1, 2.0)
# Define a 2-batch.
dist = Beta([1.0, 2.0], [4.0, 5.0])
```
"""
parameters = locals()
parameters.pop("self")
with ops.name_scope(name, values=[a, b]) as ns:
with ops.control_dependencies([
check_ops.assert_positive(a),
check_ops.assert_positive(b),
] if validate_args else []):
self._a = array_ops.identity(a, name="a")
self._b = array_ops.identity(b, name="b")
contrib_tensor_util.assert_same_float_dtype((self._a, self._b))
# Used for mean/mode/variance/entropy/sampling computations
self._a_b_sum = self._a + self._b
super(Beta, self).__init__(
dtype=self._a_b_sum.dtype,
validate_args=validate_args,
allow_nan_stats=allow_nan_stats,
is_continuous=True,
is_reparameterized=False,
parameters=parameters,
graph_parents=[self._a, self._b, self._a_b_sum],
name=ns)
开发者ID:Hwhitetooth,项目名称:tensorflow,代码行数:53,代码来源:beta.py
示例5: __init__
def __init__(self,
concentration,
rate,
validate_args=False,
allow_nan_stats=True,
name="InverseGamma"):
"""Construct InverseGamma with `concentration` and `rate` parameters.
The parameters `concentration` and `rate` must be shaped in a way that
supports broadcasting (e.g. `concentration + rate` is a valid operation).
Args:
concentration: Floating point tensor, the concentration params of the
distribution(s). Must contain only positive values.
rate: Floating point tensor, the inverse scale params of the
distribution(s). Must contain only positive values.
validate_args: Python `Boolean`, default `False`. When `True` distribution
parameters are checked for validity despite possibly degrading runtime
performance. When `False` invalid inputs may silently render incorrect
outputs.
allow_nan_stats: Python `Boolean`, default `True`. When `True`, statistics
(e.g., mean, mode, variance) use the value "`NaN`" to indicate the
result is undefined. When `False`, an exception is raised if one or
more of the statistic's batch members are undefined.
name: `String` name prefixed to Ops created by this class.
Raises:
TypeError: if `concentration` and `rate` are different dtypes.
"""
parameters = locals()
with ops.name_scope(name, values=[concentration, rate]) as ns:
with ops.control_dependencies([
check_ops.assert_positive(concentration),
check_ops.assert_positive(rate),
] if validate_args else []):
self._concentration = array_ops.identity(
concentration, name="concentration")
self._rate = array_ops.identity(rate, name="rate")
contrib_tensor_util.assert_same_float_dtype(
[self._concentration, self._rate])
super(InverseGamma, self).__init__(
dtype=self._concentration.dtype,
validate_args=validate_args,
allow_nan_stats=allow_nan_stats,
is_continuous=True,
reparameterization_type=distribution.NOT_REPARAMETERIZED,
parameters=parameters,
graph_parents=[self._concentration,
self._rate],
name=ns)
开发者ID:Jackhuang945,项目名称:tensorflow,代码行数:51,代码来源:inverse_gamma.py
示例6: __init__
def __init__(self, a, b, validate_args=True, allow_nan_stats=False,
name="Beta"):
"""Initialize a batch of Beta distributions.
Args:
a: Positive floating point tensor with shape broadcastable to
`[N1,..., Nm]` `m >= 0`. Defines this as a batch of `N1 x ... x Nm`
different Beta distributions. This also defines the
dtype of the distribution.
b: Positive floating point tensor with shape broadcastable to
`[N1,..., Nm]` `m >= 0`. Defines this as a batch of `N1 x ... x Nm`
different Beta distributions.
validate_args: Whether to assert valid values for parameters `a` and `b`,
and `x` in `prob` and `log_prob`. If `False`, correct behavior is not
guaranteed.
allow_nan_stats: Boolean, default `False`. If `False`, raise an
exception if a statistic (e.g. mean/mode/etc...) is undefined for any
batch member. If `True`, batch members with valid parameters leading to
undefined statistics will return NaN for this statistic.
name: The name to prefix Ops created by this distribution class.
Examples:
```python
# Define 1-batch.
dist = Beta(1.1, 2.0)
# Define a 2-batch.
dist = Beta([1.0, 2.0], [4.0, 5.0])
```
"""
with ops.name_scope(name, values=[a, b]):
with ops.control_dependencies([
check_ops.assert_positive(a),
check_ops.assert_positive(b)] if validate_args else []):
a = array_ops.identity(a, name="a")
b = array_ops.identity(b, name="b")
self._a = a
self._b = b
self._name = name
# Used for mean/mode/variance/entropy/sampling computations
self._a_b_sum = self._a + self._b
self._get_batch_shape = self._a_b_sum.get_shape()
self._get_event_shape = tensor_shape.TensorShape([])
self._validate_args = validate_args
self._allow_nan_stats = allow_nan_stats
开发者ID:JamesFysh,项目名称:tensorflow,代码行数:50,代码来源:beta.py
示例7: __init__
def __init__(self,
alpha,
beta,
validate_args=False,
allow_nan_stats=True,
name="Gamma"):
"""Construct Gamma distributions with parameters `alpha` and `beta`.
The parameters `alpha` and `beta` must be shaped in a way that supports
broadcasting (e.g. `alpha + beta` is a valid operation).
Args:
alpha: Floating point tensor, the shape params of the
distribution(s).
alpha must contain only positive values.
beta: Floating point tensor, the inverse scale params of the
distribution(s).
beta must contain only positive values.
validate_args: `Boolean`, default `False`. Whether to assert that
`a > 0`, `b > 0`, and that `x > 0` in the methods `prob(x)` and
`log_prob(x)`. If `validate_args` is `False` and the inputs are
invalid, correct behavior is not guaranteed.
allow_nan_stats: `Boolean`, default `True`. If `False`, raise an
exception if a statistic (e.g. mean/mode/etc...) is undefined for any
batch member. If `True`, batch members with valid parameters leading to
undefined statistics will return NaN for this statistic.
name: The name to prepend to all ops created by this distribution.
Raises:
TypeError: if `alpha` and `beta` are different dtypes.
"""
parameters = locals()
parameters.pop("self")
with ops.name_scope(name, values=[alpha, beta]) as ns:
with ops.control_dependencies([
check_ops.assert_positive(alpha),
check_ops.assert_positive(beta),
] if validate_args else []):
self._alpha = array_ops.identity(alpha, name="alpha")
self._beta = array_ops.identity(beta, name="beta")
contrib_tensor_util.assert_same_float_dtype((self._alpha, self._beta))
super(Gamma, self).__init__(
dtype=self._alpha.dtype,
validate_args=validate_args,
allow_nan_stats=allow_nan_stats,
is_continuous=True,
is_reparameterized=False,
parameters=parameters,
graph_parents=[self._alpha, self._beta],
name=ns)
开发者ID:kadeng,项目名称:tensorflow,代码行数:50,代码来源:gamma.py
示例8: __init__
def __init__(self,
df,
mu,
sigma,
validate_args=True,
allow_nan_stats=False,
name="StudentT"):
"""Construct Student's t distributions.
The distributions have degree of freedom `df`, mean `mu`, and scale `sigma`.
The parameters `df`, `mu`, and `sigma` must be shaped in a way that supports
broadcasting (e.g. `df + mu + sigma` is a valid operation).
Args:
df: Floating point tensor, the degrees of freedom of the
distribution(s). `df` must contain only positive values.
mu: Floating point tensor, the means of the distribution(s).
sigma: Floating point tensor, the scaling factor for the
distribution(s). `sigma` must contain only positive values.
Note that `sigma` is not the standard deviation of this distribution.
validate_args: Whether to assert that `df > 0, sigma > 0`. If
`validate_args` is `False` and inputs are invalid, correct behavior is
not guaranteed.
allow_nan_stats: Boolean, default `False`. If `False`, raise an
exception if a statistic (e.g. mean/mode/etc...) is undefined for any
batch member. If `True`, batch members with valid parameters leading to
undefined statistics will return NaN for this statistic.
name: The name to give Ops created by the initializer.
Raises:
TypeError: if mu and sigma are different dtypes.
"""
self._allow_nan_stats = allow_nan_stats
self._validate_args = validate_args
with ops.name_scope(name, values=[df, mu, sigma]) as scope:
with ops.control_dependencies([check_ops.assert_positive(
df), check_ops.assert_positive(sigma)] if validate_args else []):
self._df = ops.convert_to_tensor(df, name="df")
self._mu = ops.convert_to_tensor(mu, name="mu")
self._sigma = ops.convert_to_tensor(sigma, name="sigma")
contrib_tensor_util.assert_same_float_dtype(
(self._df, self._mu, self._sigma))
self._name = scope
self._get_batch_shape = common_shapes.broadcast_shape(
self._sigma.get_shape(), common_shapes.broadcast_shape(
self._df.get_shape(), self._mu.get_shape()))
self._get_event_shape = tensor_shape.TensorShape([])
开发者ID:alephman,项目名称:Tensorflow,代码行数:48,代码来源:student_t.py
示例9: __init__
def __init__(self,
skewness=0.,
tailweight=1.,
event_ndims=0,
validate_args=False,
name="sinh_arcsinh"):
"""Instantiates the `SinhArcsinh` bijector.
Args:
skewness: Skewness parameter. Float-type `Tensor`.
tailweight: Tailweight parameter. Positive `Tensor` of same `dtype` as
`skewness`
and broadcastable `shape`.
event_ndims: Python scalar indicating the number of dimensions associated
with a particular draw from the distribution.
validate_args: Python `bool` indicating whether arguments should be
checked for correctness.
name: Python `str` name given to ops managed by this object.
"""
self._graph_parents = []
self._name = name
self._validate_args = validate_args
with self._name_scope("init", values=[skewness, tailweight]):
self._skewness = ops.convert_to_tensor(skewness, name="skewness")
self._tailweight = ops.convert_to_tensor(tailweight, name="tailweight")
check_ops.assert_same_float_dtype([self._skewness, self._tailweight])
if validate_args:
self._tailweight = control_flow_ops.with_dependencies([
check_ops.assert_positive(
self._tailweight,
message="Argument tailweight was not positive")
], self._tailweight)
super(SinhArcsinh, self).__init__(
event_ndims=event_ndims, validate_args=validate_args, name=name)
开发者ID:AutumnQYN,项目名称:tensorflow,代码行数:34,代码来源:sinh_arcsinh_impl.py
示例10: _maybe_assert_valid_sample
def _maybe_assert_valid_sample(self, x):
check_ops.assert_same_float_dtype(tensors=[x], dtype=self.dtype)
if not self.validate_args:
return x
return control_flow_ops.with_dependencies([
check_ops.assert_positive(x),
], x)
开发者ID:aritratony,项目名称:tensorflow,代码行数:7,代码来源:gamma.py
示例11: __init__
def __init__(self,
lam,
validate_args=False,
allow_nan_stats=True,
name="Poisson"):
"""Construct Poisson distributions.
Args:
lam: Floating point tensor, the rate parameter of the
distribution(s). `lam` must be positive.
validate_args: `Boolean`, default `False`. Whether to assert that
`lam > 0` as well as inputs to pmf computations are non-negative
integers. If validate_args is `False`, then `pmf` computations might
return `NaN`, but can be evaluated at any real value.
allow_nan_stats: `Boolean`, default `True`. If `False`, raise an
exception if a statistic (e.g. mean/mode/etc...) is undefined for any
batch member. If `True`, batch members with valid parameters leading to
undefined statistics will return NaN for this statistic.
name: A name for this distribution.
"""
parameters = locals()
parameters.pop("self")
with ops.name_scope(name, values=[lam]) as ns:
with ops.control_dependencies([check_ops.assert_positive(lam)] if
validate_args else []):
self._lam = array_ops.identity(lam, name="lam")
super(Poisson, self).__init__(
dtype=self._lam.dtype,
is_continuous=False,
reparameterization_type=distribution.NOT_REPARAMETERIZED,
validate_args=validate_args,
allow_nan_stats=allow_nan_stats,
parameters=parameters,
graph_parents=[self._lam],
name=ns)
开发者ID:ivankreso,项目名称:tensorflow,代码行数:35,代码来源:poisson.py
示例12: calculate_reshape
def calculate_reshape(original_shape, new_shape, validate=False, name=None):
"""Calculates the reshaped dimensions (replacing up to one -1 in reshape)."""
batch_shape_static = tensor_util.constant_value_as_shape(new_shape)
if batch_shape_static.is_fully_defined():
return np.int32(batch_shape_static.as_list()), batch_shape_static, []
with ops.name_scope(name, "calculate_reshape", [original_shape, new_shape]):
original_size = math_ops.reduce_prod(original_shape)
implicit_dim = math_ops.equal(new_shape, -1)
size_implicit_dim = (
original_size // math_ops.maximum(1, -math_ops.reduce_prod(new_shape)))
new_ndims = array_ops.shape(new_shape)
expanded_new_shape = array_ops.where( # Assumes exactly one `-1`.
implicit_dim, array_ops.fill(new_ndims, size_implicit_dim), new_shape)
validations = [] if not validate else [
check_ops.assert_rank(
original_shape, 1, message="Original shape must be a vector."),
check_ops.assert_rank(
new_shape, 1, message="New shape must be a vector."),
check_ops.assert_less_equal(
math_ops.count_nonzero(implicit_dim, dtype=dtypes.int32),
1,
message="At most one dimension can be unknown."),
check_ops.assert_positive(
expanded_new_shape, message="Shape elements must be >=-1."),
check_ops.assert_equal(
math_ops.reduce_prod(expanded_new_shape),
original_size,
message="Shape sizes do not match."),
]
return expanded_new_shape, batch_shape_static, validations
开发者ID:Ajaycs99,项目名称:tensorflow,代码行数:30,代码来源:batch_reshape.py
示例13: __init__
def __init__(self, mu, sigma, name="Normal"):
"""Construct Normal distributions with mean and stddev `mu` and `sigma`.
The parameters `mu` and `sigma` must be shaped in a way that supports
broadcasting (e.g. `mu + sigma` is a valid operation).
Args:
mu: `float` or `double` tensor, the means of the distribution(s).
sigma: `float` or `double` tensor, the stddevs of the distribution(s).
sigma must contain only positive values.
name: The name to give Ops created by the initializer.
Raises:
TypeError: if mu and sigma are different dtypes.
"""
with ops.op_scope([mu, sigma], name):
mu = ops.convert_to_tensor(mu)
sigma = ops.convert_to_tensor(sigma)
with ops.control_dependencies([check_ops.assert_positive(sigma)]):
self._name = name
self._mu = array_ops.identity(mu, name="mu")
self._sigma = array_ops.identity(sigma, name="sigma")
self._batch_shape = self._ones().get_shape()
self._event_shape = tensor_shape.TensorShape([])
contrib_tensor_util.assert_same_float_dtype((mu, sigma))
开发者ID:Assassin0028,项目名称:tensorflow,代码行数:26,代码来源:normal.py
示例14: __init__
def __init__(self, mu, sigma, validate_args=True, allow_nan_stats=False, name="Normal"):
"""Construct Normal distributions with mean and stddev `mu` and `sigma`.
The parameters `mu` and `sigma` must be shaped in a way that supports
broadcasting (e.g. `mu + sigma` is a valid operation).
Args:
mu: Floating point tensor, the means of the distribution(s).
sigma: Floating point tensor, the stddevs of the distribution(s).
sigma must contain only positive values.
validate_args: Whether to assert that `sigma > 0`. If `validate_args` is
`False`, correct output is not guaranteed when input is invalid.
allow_nan_stats: Boolean, default `False`. If `False`, raise an
exception if a statistic (e.g. mean/mode/etc...) is undefined for any
batch member. If `True`, batch members with valid parameters leading to
undefined statistics will return NaN for this statistic.
name: The name to give Ops created by the initializer.
Raises:
TypeError: if mu and sigma are different dtypes.
"""
with ops.name_scope(name, values=[mu, sigma]):
with ops.control_dependencies([check_ops.assert_positive(sigma)] if validate_args else []):
self._mu = array_ops.identity(mu, name="mu")
self._sigma = array_ops.identity(sigma, name="sigma")
contrib_tensor_util.assert_same_float_dtype((self._mu, self._sigma))
super(Normal, self).__init__(
dtype=self._sigma.dtype,
parameters={"mu": self._mu, "sigma": self._sigma},
is_reparameterized=True,
validate_args=validate_args,
allow_nan_stats=allow_nan_stats,
name=name,
)
开发者ID:caisq,项目名称:tensorflow,代码行数:34,代码来源:normal.py
示例15: _maybe_assert_valid_x
def _maybe_assert_valid_x(self, x):
if not self.validate_args:
return x
is_valid = check_ops.assert_positive(
x[..., 1:] - x[..., :-1],
message="Forward transformation input must be strictly increasing.")
return control_flow_ops.with_dependencies([is_valid], x)
开发者ID:Jackiefan,项目名称:tensorflow,代码行数:7,代码来源:ordered.py
示例16: __init__
def __init__(self,
scale,
validate_args=False,
allow_nan_stats=True,
name="HalfNormal"):
"""Construct HalfNormals with scale `scale`.
Args:
scale: Floating point tensor; the scales of the distribution(s).
Must contain only positive values.
validate_args: Python `bool`, default `False`. When `True` distribution
parameters are checked for validity despite possibly degrading runtime
performance. When `False` invalid inputs may silently render incorrect
outputs.
allow_nan_stats: Python `bool`, default `True`. When `True`,
statistics (e.g., mean, mode, variance) use the value "`NaN`" to
indicate the result is undefined. When `False`, an exception is raised
if one or more of the statistic's batch members are undefined.
name: Python `str` name prefixed to Ops created by this class.
"""
parameters = locals()
with ops.name_scope(name, values=[scale]) as name:
with ops.control_dependencies([check_ops.assert_positive(scale)] if
validate_args else []):
self._scale = array_ops.identity(scale, name="scale")
super(HalfNormal, self).__init__(
dtype=self._scale.dtype,
reparameterization_type=distribution.FULLY_REPARAMETERIZED,
validate_args=validate_args,
allow_nan_stats=allow_nan_stats,
parameters=parameters,
graph_parents=[self._scale],
name=name)
开发者ID:Jackiefan,项目名称:tensorflow,代码行数:33,代码来源:half_normal.py
示例17: __init__
def __init__(self,
rate,
validate_args=False,
allow_nan_stats=True,
name="Poisson"):
"""Initialize a batch of Poisson distributions.
Args:
rate: Floating point tensor, the rate parameter of the
distribution(s). `rate` must be positive.
validate_args: Python `Boolean`, default `False`. When `True` distribution
parameters are checked for validity despite possibly degrading runtime
performance. When `False` invalid inputs may silently render incorrect
outputs.
allow_nan_stats: Python `Boolean`, default `True`. When `True`, statistics
(e.g., mean, mode, variance) use the value "`NaN`" to indicate the
result is undefined. When `False`, an exception is raised if one or
more of the statistic's batch members are undefined.
name: `String` name prefixed to Ops created by this class.
"""
parameters = locals()
with ops.name_scope(name, values=[rate]) as ns:
with ops.control_dependencies([check_ops.assert_positive(rate)] if
validate_args else []):
self._rate = array_ops.identity(rate, name="rate")
super(Poisson, self).__init__(
dtype=self._rate.dtype,
is_continuous=False,
reparameterization_type=distribution.NOT_REPARAMETERIZED,
validate_args=validate_args,
allow_nan_stats=allow_nan_stats,
parameters=parameters,
graph_parents=[self._rate],
name=ns)
开发者ID:Jackhuang945,项目名称:tensorflow,代码行数:34,代码来源:poisson.py
示例18: _log_cdf
def _log_cdf(self, x):
x = control_flow_ops.with_dependencies([check_ops.assert_positive(x)] if
self.validate_args else [], x)
contrib_tensor_util.assert_same_float_dtype(tensors=[x], dtype=self.dtype)
# Note that igamma returns the regularized incomplete gamma function,
# which is what we want for the CDF.
return math_ops.log(math_ops.igamma(self.alpha, self.beta * x))
开发者ID:Nishant23,项目名称:tensorflow,代码行数:7,代码来源:gamma.py
示例19: __init__
def __init__(self,
lam,
validate_args=True,
allow_nan_stats=False,
name="Poisson"):
"""Construct Poisson distributions.
Args:
lam: Floating point tensor, the rate parameter of the
distribution(s). `lam` must be positive.
validate_args: Whether to assert that `lam > 0` as well as inputs to
pmf computations are non-negative integers. If validate_args is
`False`, then `pmf` computations might return NaN, as well as
can be evaluated at any real value.
allow_nan_stats: Boolean, default `False`. If `False`, raise an
exception if a statistic (e.g. mean/mode/etc...) is undefined for any
batch member. If `True`, batch members with valid parameters leading to
undefined statistics will return NaN for this statistic.
name: A name for this distribution.
"""
with ops.name_scope(name, values=[lam]) as scope:
self._name = scope
with ops.control_dependencies(
[check_ops.assert_positive(lam)] if validate_args else []):
self._lam = array_ops.identity(lam, name="lam")
self._validate_args = validate_args
self._allow_nan_stats = allow_nan_stats
开发者ID:JamesFysh,项目名称:tensorflow,代码行数:27,代码来源:poisson.py
示例20: __init__
def __init__(self,
loc=0.,
scale=1.,
validate_args=False,
name="gumbel"):
"""Instantiates the `Gumbel` bijector.
Args:
loc: Float-like `Tensor` that is the same dtype and is
broadcastable with `scale`.
This is `loc` in `Y = g(X) = exp(-exp(-(X - loc) / scale))`.
scale: Positive Float-like `Tensor` that is the same dtype and is
broadcastable with `loc`.
This is `scale` in `Y = g(X) = exp(-exp(-(X - loc) / scale))`.
validate_args: Python `bool` indicating whether arguments should be
checked for correctness.
name: Python `str` name given to ops managed by this object.
"""
self._graph_parents = []
self._name = name
self._validate_args = validate_args
with self._name_scope("init", values=[loc, scale]):
self._loc = ops.convert_to_tensor(loc, name="loc")
self._scale = ops.convert_to_tensor(scale, name="scale")
check_ops.assert_same_float_dtype([self._loc, self._scale])
if validate_args:
self._scale = control_flow_ops.with_dependencies([
check_ops.assert_positive(
self._scale, message="Argument scale was not positive")
], self._scale)
super(Gumbel, self).__init__(
validate_args=validate_args,
forward_min_event_ndims=0,
name=name)
开发者ID:Ajaycs99,项目名称:tensorflow,代码行数:35,代码来源:gumbel.py
注:本文中的tensorflow.python.ops.check_ops.assert_positive函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论