Skip to content

Commit

Permalink
BREAKING CHANGE: Remove deprecated behavior of Poisson.{rate,log_rate}.
Browse files Browse the repository at this point in the history
We now return None when the `rate` or `log_rate` parameter was not specified when building the model -- e.g.: `Poisson(rate=[...]).log_rate` is now None and `Poisson(log_rate=[...]).rate` is now None.  If the previous behavior is needed, use methods `rate_parameter()` and `log_rate_parameter()`.

PiperOrigin-RevId: 287219881
  • Loading branch information
jburnim authored and tensorflower-gardener committed Dec 26, 2019
1 parent be9f15e commit 98b48ba
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 23 deletions.
22 changes: 1 addition & 21 deletions tensorflow_probability/python/distributions/poisson.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
from tensorflow_probability.python.internal import dtype_util
from tensorflow_probability.python.internal import reparameterization
from tensorflow_probability.python.internal import tensor_util
from tensorflow.python.util import deprecation # pylint: disable=g-direct-tensorflow-import


__all__ = [
'Poisson',
Expand Down Expand Up @@ -118,15 +118,11 @@ def _params_event_ndims(cls):
@property
def rate(self):
"""Rate parameter."""
if self._rate is None:
return self._rate_deprecated_behavior()
return self._rate

@property
def log_rate(self):
"""Log rate parameter."""
if self._log_rate is None:
return self._log_rate_deprecated_behavior()
return self._log_rate

@property
Expand Down Expand Up @@ -219,22 +215,6 @@ def _log_rate_parameter_no_checks(self):
return tf.math.log(self._rate)
return tf.identity(self._log_rate)

@deprecation.deprecated(
'2019-10-01',
'The `rate` property will return `None` when the distribution is '
'parameterized with `rate=None`. Use `rate_parameter()` instead.',
warn_once=True)
def _rate_deprecated_behavior(self):
return self.rate_parameter()

@deprecation.deprecated(
'2019-10-01',
'The `log_rate` property will return `None` when the distribution is '
'parameterized with `log_rate=None`. Use `log_rate_parameter()` instead.',
warn_once=True)
def _log_rate_deprecated_behavior(self):
return self.log_rate_parameter()

def _default_event_space_bijector(self):
return

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -371,7 +371,7 @@ def _sample_n(self, n, seed=None):
delta=self._quadrature_size,
dtype=ids.dtype)
ids = ids + offset
rate = tf.gather(tf.reshape(dist.rate, shape=[-1]), ids)
rate = tf.gather(tf.reshape(dist.rate_parameter(), shape=[-1]), ids)
rate = tf.reshape(
rate, shape=concat_vectors([n], self._batch_shape_tensor(
distributions=distributions)))
Expand Down
3 changes: 2 additions & 1 deletion tensorflow_probability/python/distributions/poisson_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,8 @@ def testPoissonLogPmfContinuousRelaxation(self):
rate=lam, interpolate_nondiscrete=True, validate_args=False)

expected_continuous_log_pmf = (
x * poisson.log_rate - tf.math.lgamma(1. + x) - poisson.rate)
x * poisson.log_rate_parameter()
- tf.math.lgamma(1. + x) - poisson.rate_parameter())
expected_continuous_log_pmf = tf.where(
x >= 0., expected_continuous_log_pmf,
dtype_util.as_numpy_dtype(
Expand Down

0 comments on commit 98b48ba

Please sign in to comment.