From 67a55b2ef5e94da203991ed102c9e41d085a840a Mon Sep 17 00:00:00 2001 From: rif Date: Thu, 21 Jun 2018 22:58:33 -0700 Subject: [PATCH] Move bijectors from a distributions/bijectors subdirectory to a new bijectors "top-level" directory. PiperOrigin-RevId: 201640254 --- .../Bayesian_Gaussian_Mixture_Model.ipynb | 2 +- .../jupyter_notebooks/Gaussian_Copula.ipynb | 2 +- ...ding_TensorFlow_Distributions_Shapes.ipynb | 2 +- tensorflow_probability/python/__init__.py | 2 + tensorflow_probability/python/bijectors/BUILD | 443 ++++++++++++++++++ .../python/bijectors/__init__.py | 74 +++ .../bijectors/absolute_value.py | 0 .../bijectors/absolute_value_test.py | 5 +- .../{distributions => }/bijectors/affine.py | 2 +- .../bijectors/affine_linear_operator.py | 2 +- .../bijectors/affine_linear_operator_test.py | 5 +- .../bijectors/affine_scalar.py | 0 .../bijectors/affine_scalar_test.py | 3 +- .../bijectors/affine_test.py | 5 +- .../bijectors/batch_normalization.py | 0 .../bijectors/batch_normalization_test.py | 5 +- .../{distributions => }/bijectors/chain.py | 0 .../bijectors/chain_test.py | 5 +- .../bijectors/cholesky_outer_product.py | 0 .../bijectors/cholesky_outer_product_test.py | 26 +- .../bijectors/conditional_bijector.py | 0 .../bijectors/conditional_bijector_test.py | 4 +- .../{distributions => }/bijectors/exp.py | 2 +- .../{distributions => }/bijectors/exp_test.py | 5 +- .../bijectors/fill_triangular.py | 0 .../bijectors/fill_triangular_test.py | 10 +- .../{distributions => }/bijectors/gumbel.py | 0 .../bijectors/gumbel_test.py | 5 +- .../{distributions => }/bijectors/inline.py | 0 .../bijectors/inline_test.py | 5 +- .../{distributions => }/bijectors/invert.py | 0 .../bijectors/invert_test.py | 25 +- .../bijectors/kumaraswamy.py | 0 .../bijectors/kumaraswamy_bijector_test.py | 5 +- .../bijectors/masked_autoregressive.py | 0 .../bijectors/masked_autoregressive_test.py | 7 +- .../bijectors/matrix_inverse_tril.py | 0 .../bijectors/matrix_inverse_tril_test.py | 20 +- .../{distributions => }/bijectors/ordered.py | 0 .../bijectors/ordered_test.py | 0 .../{distributions => }/bijectors/permute.py | 0 .../bijectors/permute_test.py | 5 +- .../bijectors/power_transform.py | 0 .../bijectors/power_transform_test.py | 5 +- .../{distributions => }/bijectors/real_nvp.py | 0 .../bijectors/real_nvp_test.py | 5 +- .../{distributions => }/bijectors/reshape.py | 0 .../bijectors/reshape_test.py | 5 +- .../bijectors/scale_tril.py | 10 +- .../bijectors/scale_tril_test.py | 12 +- .../{distributions => bijectors}/shape.py | 0 .../shape_test.py | 2 +- .../{distributions => }/bijectors/sigmoid.py | 0 .../bijectors/sigmoid_test.py | 5 +- .../bijectors/sinh_arcsinh.py | 0 .../bijectors/sinh_arcsinh_bijector_test.py | 5 +- .../bijectors/softmax_centered.py | 0 .../bijectors/softmax_centered_test.py | 5 +- .../{distributions => }/bijectors/softplus.py | 0 .../bijectors/softplus_test.py | 5 +- .../{distributions => }/bijectors/softsign.py | 0 .../bijectors/softsign_test.py | 5 +- .../{distributions => }/bijectors/square.py | 0 .../bijectors/square_test.py | 8 +- .../bijectors/transform_diagonal.py | 0 .../bijectors/transform_diagonal_test.py | 8 +- .../{distributions => }/bijectors/weibull.py | 0 .../bijectors/weibull_test.py | 5 +- .../python/distributions/BUILD | 438 +---------------- .../python/distributions/__init__.py | 3 - .../distributions/autoregressive_test.py | 2 +- .../distributions/bijectors/__init__.py | 74 --- ...nditional_transformed_distribution_test.py | 2 +- .../python/distributions/kumaraswamy.py | 2 +- .../python/distributions/lognormal.py | 2 +- .../python/distributions/mvn_diag_test.py | 2 +- .../distributions/mvn_linear_operator.py | 2 +- .../python/distributions/poisson_lognormal.py | 2 +- .../python/distributions/relaxed_bernoulli.py | 2 +- .../relaxed_onehot_categorical.py | 2 +- .../python/distributions/sinh_arcsinh.py | 2 +- .../transformed_distribution_test.py | 6 +- .../distributions/vector_diffeomixture.py | 4 +- .../vector_exponential_linear_operator.py | 2 +- .../distributions/vector_laplace_diag_test.py | 2 +- .../vector_laplace_linear_operator.py | 2 +- .../distributions/vector_sinh_arcsinh_diag.py | 2 +- .../python/distributions/vector_student_t.py | 4 +- .../python/mcmc/transformed_kernel_test.py | 2 +- 89 files changed, 624 insertions(+), 696 deletions(-) create mode 100644 tensorflow_probability/python/bijectors/BUILD create mode 100644 tensorflow_probability/python/bijectors/__init__.py rename tensorflow_probability/python/{distributions => }/bijectors/absolute_value.py (100%) rename tensorflow_probability/python/{distributions => }/bijectors/absolute_value_test.py (96%) rename tensorflow_probability/python/{distributions => }/bijectors/affine.py (99%) rename tensorflow_probability/python/{distributions => }/bijectors/affine_linear_operator.py (98%) rename tensorflow_probability/python/{distributions => }/bijectors/affine_linear_operator_test.py (98%) rename tensorflow_probability/python/{distributions => }/bijectors/affine_scalar.py (100%) rename tensorflow_probability/python/{distributions => }/bijectors/affine_scalar_test.py (99%) rename tensorflow_probability/python/{distributions => }/bijectors/affine_test.py (99%) rename tensorflow_probability/python/{distributions => }/bijectors/batch_normalization.py (100%) rename tensorflow_probability/python/{distributions => }/bijectors/batch_normalization_test.py (99%) rename tensorflow_probability/python/{distributions => }/bijectors/chain.py (100%) rename tensorflow_probability/python/{distributions => }/bijectors/chain_test.py (98%) rename tensorflow_probability/python/{distributions => }/bijectors/cholesky_outer_product.py (100%) rename tensorflow_probability/python/{distributions => }/bijectors/cholesky_outer_product_test.py (87%) rename tensorflow_probability/python/{distributions => }/bijectors/conditional_bijector.py (100%) rename tensorflow_probability/python/{distributions => }/bijectors/conditional_bijector_test.py (96%) rename tensorflow_probability/python/{distributions => }/bijectors/exp.py (95%) rename tensorflow_probability/python/{distributions => }/bijectors/exp_test.py (96%) rename tensorflow_probability/python/{distributions => }/bijectors/fill_triangular.py (100%) rename tensorflow_probability/python/{distributions => }/bijectors/fill_triangular_test.py (93%) rename tensorflow_probability/python/{distributions => }/bijectors/gumbel.py (100%) rename tensorflow_probability/python/{distributions => }/bijectors/gumbel_test.py (96%) rename tensorflow_probability/python/{distributions => }/bijectors/inline.py (100%) rename tensorflow_probability/python/{distributions => }/bijectors/inline_test.py (97%) rename tensorflow_probability/python/{distributions => }/bijectors/invert.py (100%) rename tensorflow_probability/python/{distributions => }/bijectors/invert_test.py (84%) rename tensorflow_probability/python/{distributions => }/bijectors/kumaraswamy.py (100%) rename tensorflow_probability/python/{distributions => }/bijectors/kumaraswamy_bijector_test.py (97%) rename tensorflow_probability/python/{distributions => }/bijectors/masked_autoregressive.py (100%) rename tensorflow_probability/python/{distributions => }/bijectors/masked_autoregressive_test.py (96%) rename tensorflow_probability/python/{distributions => }/bijectors/matrix_inverse_tril.py (100%) rename tensorflow_probability/python/{distributions => }/bijectors/matrix_inverse_tril_test.py (93%) rename tensorflow_probability/python/{distributions => }/bijectors/ordered.py (100%) rename tensorflow_probability/python/{distributions => }/bijectors/ordered_test.py (100%) rename tensorflow_probability/python/{distributions => }/bijectors/permute.py (100%) rename tensorflow_probability/python/{distributions => }/bijectors/permute_test.py (97%) rename tensorflow_probability/python/{distributions => }/bijectors/power_transform.py (100%) rename tensorflow_probability/python/{distributions => }/bijectors/power_transform_test.py (96%) rename tensorflow_probability/python/{distributions => }/bijectors/real_nvp.py (100%) rename tensorflow_probability/python/{distributions => }/bijectors/real_nvp_test.py (98%) rename tensorflow_probability/python/{distributions => }/bijectors/reshape.py (100%) rename tensorflow_probability/python/{distributions => }/bijectors/reshape_test.py (99%) rename tensorflow_probability/python/{distributions => }/bijectors/scale_tril.py (90%) rename tensorflow_probability/python/{distributions => }/bijectors/scale_tril_test.py (89%) rename tensorflow_probability/python/{distributions => bijectors}/shape.py (100%) rename tensorflow_probability/python/{distributions => bijectors}/shape_test.py (99%) rename tensorflow_probability/python/{distributions => }/bijectors/sigmoid.py (100%) rename tensorflow_probability/python/{distributions => }/bijectors/sigmoid_test.py (96%) rename tensorflow_probability/python/{distributions => }/bijectors/sinh_arcsinh.py (100%) rename tensorflow_probability/python/{distributions => }/bijectors/sinh_arcsinh_bijector_test.py (98%) rename tensorflow_probability/python/{distributions => }/bijectors/softmax_centered.py (100%) rename tensorflow_probability/python/{distributions => }/bijectors/softmax_centered_test.py (98%) rename tensorflow_probability/python/{distributions => }/bijectors/softplus.py (100%) rename tensorflow_probability/python/{distributions => }/bijectors/softplus_test.py (98%) rename tensorflow_probability/python/{distributions => }/bijectors/softsign.py (100%) rename tensorflow_probability/python/{distributions => }/bijectors/softsign_test.py (98%) rename tensorflow_probability/python/{distributions => }/bijectors/square.py (100%) rename tensorflow_probability/python/{distributions => }/bijectors/square_test.py (91%) rename tensorflow_probability/python/{distributions => }/bijectors/transform_diagonal.py (100%) rename tensorflow_probability/python/{distributions => }/bijectors/transform_diagonal_test.py (93%) rename tensorflow_probability/python/{distributions => }/bijectors/weibull.py (100%) rename tensorflow_probability/python/{distributions => }/bijectors/weibull_test.py (97%) delete mode 100644 tensorflow_probability/python/distributions/bijectors/__init__.py diff --git a/tensorflow_probability/examples/jupyter_notebooks/Bayesian_Gaussian_Mixture_Model.ipynb b/tensorflow_probability/examples/jupyter_notebooks/Bayesian_Gaussian_Mixture_Model.ipynb index 2c96a29cce..4bfb8d995c 100644 --- a/tensorflow_probability/examples/jupyter_notebooks/Bayesian_Gaussian_Mixture_Model.ipynb +++ b/tensorflow_probability/examples/jupyter_notebooks/Bayesian_Gaussian_Mixture_Model.ipynb @@ -101,7 +101,7 @@ "from tensorflow.python.ops.distributions import util as distribution_util\n", "\n", "tfd = tfp.distributions\n", - "tfb = tfp.distributions.bijectors" + "tfb = tfp.bijectors" ] }, { diff --git a/tensorflow_probability/examples/jupyter_notebooks/Gaussian_Copula.ipynb b/tensorflow_probability/examples/jupyter_notebooks/Gaussian_Copula.ipynb index ac6180137c..3caa9bfa5b 100644 --- a/tensorflow_probability/examples/jupyter_notebooks/Gaussian_Copula.ipynb +++ b/tensorflow_probability/examples/jupyter_notebooks/Gaussian_Copula.ipynb @@ -20,7 +20,7 @@ "import tensorflow as tf\n", "import tensorflow_probability as tfp\n", "tfd = tfp.distributions\n", - "tfb = tfp.distributions.bijectors" + "tfb = tfp.bijectors" ] }, { diff --git a/tensorflow_probability/examples/jupyter_notebooks/Understanding_TensorFlow_Distributions_Shapes.ipynb b/tensorflow_probability/examples/jupyter_notebooks/Understanding_TensorFlow_Distributions_Shapes.ipynb index 8baa613d0b..4040267a89 100644 --- a/tensorflow_probability/examples/jupyter_notebooks/Understanding_TensorFlow_Distributions_Shapes.ipynb +++ b/tensorflow_probability/examples/jupyter_notebooks/Understanding_TensorFlow_Distributions_Shapes.ipynb @@ -30,7 +30,7 @@ "import tensorflow as tf\n", "import tensorflow_probability as tfp\n", "tfd = tfp.distributions\n", - "tfb = tfp.distributions.bijectors\n", + "tfb = tfp.bijectors\n", "\n", "tfe = tf.contrib.eager\n", "tfe.enable_eager_execution()\n", diff --git a/tensorflow_probability/python/__init__.py b/tensorflow_probability/python/__init__.py index a506192163..35f45c0483 100644 --- a/tensorflow_probability/python/__init__.py +++ b/tensorflow_probability/python/__init__.py @@ -18,6 +18,7 @@ from __future__ import division from __future__ import print_function +from tensorflow_probability.python import bijectors from tensorflow_probability.python import distributions from tensorflow_probability.python import edward2 from tensorflow_probability.python import glm @@ -34,6 +35,7 @@ _allowed_symbols = [ '__version__', + 'bijectors', 'distributions', 'edward2', 'glm', diff --git a/tensorflow_probability/python/bijectors/BUILD b/tensorflow_probability/python/bijectors/BUILD new file mode 100644 index 0000000000..08aa7a650c --- /dev/null +++ b/tensorflow_probability/python/bijectors/BUILD @@ -0,0 +1,443 @@ +# Copyright 2018 The TensorFlow Probability Authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# ============================================================================ +# Description: +# Contains ops for bijectors. +# APIs here are meant to evolve over time. + +licenses(["notice"]) # Apache 2.0 + +package( + default_visibility = [ + "//tensorflow_probability:__subpackages__", + ], +) + +exports_files(["LICENSE"]) + +py_library( + name = "bijectors", + srcs = glob( + ["*.py"], + exclude = glob([ + "*_test.py", + ]) + ["shape.py"], + ), + srcs_version = "PY2AND3", + deps = [ + ":shape", + # numpy dep, + # tensorflow dep, + "//tensorflow_probability/python/internal:distribution_util", + ], +) + +py_library( + name = "shape", + srcs = ["shape.py"], + srcs_version = "PY2AND3", + deps = [ + # tensorflow dep, + ], +) + +py_test( + name = "shape_test", + size = "medium", + srcs = ["shape_test.py"], + deps = [ + ":shape", + # numpy dep, + # tensorflow dep, + "//tensorflow_probability", + ], +) + +py_test( + name = "conditional_bijector_test", + size = "small", + srcs = ["conditional_bijector_test.py"], + deps = [ + ":bijectors", + # numpy dep, + # six dep, + # tensorflow dep, + "//tensorflow_probability", + ], +) + +py_test( + name = "absolute_value_test", + size = "small", + srcs = ["absolute_value_test.py"], + deps = [ + ":bijectors", + # numpy dep, + # six dep, + # tensorflow dep, + "//tensorflow_probability", + ], +) + +py_test( + name = "affine_test", + size = "large", + srcs = ["affine_test.py"], + shard_count = 5, + tags = ["noasan"], # times out b/63678675 + deps = [ + ":bijectors", + # numpy dep, + # six dep, + # tensorflow dep, + "//tensorflow_probability", + ], +) + +py_test( + name = "affine_scalar_test", + size = "small", + srcs = ["affine_scalar_test.py"], + deps = [ + ":bijectors", + # numpy dep, + # six dep, + # tensorflow dep, + "//tensorflow_probability", + ], +) + +py_test( + name = "affine_linear_operator_test", + size = "small", + srcs = ["affine_linear_operator_test.py"], + deps = [ + ":bijectors", + # numpy dep, + # six dep, + # tensorflow dep, + "//tensorflow_probability", + ], +) + +py_test( + name = "batch_normalization_test", + size = "small", + srcs = ["batch_normalization_test.py"], + deps = [ + ":bijectors", + # numpy dep, + # tensorflow dep, + "//tensorflow_probability", + "//tensorflow_probability/python/internal:test_util", + ], +) + +py_test( + name = "chain_test", + size = "small", + srcs = ["chain_test.py"], + deps = [ + ":bijectors", + # numpy dep, + # six dep, + # tensorflow dep, + "//tensorflow_probability", + ], +) + +py_test( + name = "cholesky_outer_product_test", + size = "small", + srcs = ["cholesky_outer_product_test.py"], + deps = [ + ":bijectors", + # numpy dep, + # six dep, + # tensorflow dep, + "//tensorflow_probability", + ], +) + +py_test( + name = "exp_test", + size = "small", + srcs = ["exp_test.py"], + deps = [ + ":bijectors", + # numpy dep, + # six dep, + # tensorflow dep, + "//tensorflow_probability", + ], +) + +py_test( + name = "fill_triangular_test", + size = "small", + srcs = ["fill_triangular_test.py"], + deps = [ + ":bijectors", + # numpy dep, + # six dep, + # tensorflow dep, + "//tensorflow_probability", + ], +) + +py_test( + name = "gumbel_test", + size = "small", + srcs = ["gumbel_test.py"], + deps = [ + ":bijectors", + # numpy dep, + # six dep, + # tensorflow dep, + "//tensorflow_probability", + ], +) + +py_test( + name = "inline_test", + size = "small", + srcs = ["inline_test.py"], + deps = [ + ":bijectors", + # numpy dep, + # six dep, + # tensorflow dep, + "//tensorflow_probability", + ], +) + +py_test( + name = "invert_test", + size = "small", + srcs = ["invert_test.py"], + deps = [ + ":bijectors", + # numpy dep, + # six dep, + # tensorflow dep, + "//tensorflow_probability", + ], +) + +py_test( + name = "kumaraswamy_bijector_test", + size = "small", + srcs = ["kumaraswamy_bijector_test.py"], + deps = [ + ":bijectors", + # numpy dep, + # six dep, + # tensorflow dep, + "//tensorflow_probability", + ], +) + +py_test( + name = "masked_autoregressive_test", + size = "small", + srcs = ["masked_autoregressive_test.py"], + deps = [ + ":bijectors", + # numpy dep, + # tensorflow dep, + "//tensorflow_probability", + "//tensorflow_probability/python/internal:test_util", + ], +) + +py_test( + name = "matrix_inverse_tril_test", + size = "small", + srcs = ["matrix_inverse_tril_test.py"], + deps = [ + ":bijectors", + # numpy dep, + # tensorflow dep, + "//tensorflow_probability", + ], +) + +py_test( + name = "real_nvp_test", + size = "small", + srcs = ["real_nvp_test.py"], + deps = [ + ":bijectors", + # numpy dep, + # tensorflow dep, + "//tensorflow_probability", + "//tensorflow_probability/python/internal:test_util", + ], +) + +py_test( + name = "permute_test", + size = "small", + srcs = ["permute_test.py"], + deps = [ + ":bijectors", + # numpy dep, + # tensorflow dep, + "//tensorflow_probability", + ], +) + +py_test( + name = "power_transform_test", + size = "small", + srcs = ["power_transform_test.py"], + deps = [ + ":bijectors", + # numpy dep, + # six dep, + # tensorflow dep, + "//tensorflow_probability", + ], +) + +py_test( + name = "reshape_test", + size = "medium", + srcs = ["reshape_test.py"], + deps = [ + ":bijectors", + # numpy dep, + # tensorflow dep, + "//tensorflow_probability", + ], +) + +py_test( + name = "scale_tril_test", + size = "medium", + srcs = ["scale_tril_test.py"], + deps = [ + ":bijectors", + # numpy dep, + # tensorflow dep, + "//tensorflow_probability", + ], +) + +py_test( + name = "sigmoid_test", + size = "small", + srcs = ["sigmoid_test.py"], + deps = [ + ":bijectors", + # numpy dep, + # six dep, + # tensorflow dep, + "//tensorflow_probability", + ], +) + +# Tests for SinhArcSinh bijector. The file name has the extra "_bijector" to +# avoid BUILD rule name conflicts with the distribution by the same name. +py_test( + name = "sinh_arcsinh_bijector_test", + size = "small", + srcs = ["sinh_arcsinh_bijector_test.py"], + tags = ["no_windows"], # TODO: needs investigation on Windows + deps = [ + ":bijectors", + # numpy dep, + # six dep, + # tensorflow dep, + "//tensorflow_probability", + ], +) + +py_test( + name = "softmax_centered_test", + size = "small", + srcs = ["softmax_centered_test.py"], + deps = [ + ":bijectors", + # numpy dep, + # six dep, + # tensorflow dep, + "//tensorflow_probability", + ], +) + +py_test( + name = "softplus_test", + size = "small", + srcs = ["softplus_test.py"], + deps = [ + ":bijectors", + # numpy dep, + # six dep, + # tensorflow dep, + "//tensorflow_probability", + ], +) + +py_test( + name = "softsign_test", + size = "small", + srcs = ["softsign_test.py"], + deps = [ + ":bijectors", + # numpy dep, + # six dep, + # tensorflow dep, + "//tensorflow_probability", + ], +) + +py_test( + name = "square_test", + size = "small", + srcs = ["square_test.py"], + deps = [ + ":bijectors", + # numpy dep, + # six dep, + # tensorflow dep, + "//tensorflow_probability", + ], +) + +py_test( + name = "transform_diagonal_test", + size = "small", + srcs = ["transform_diagonal_test.py"], + deps = [ + ":bijectors", + # numpy dep, + # six dep, + # tensorflow dep, + "//tensorflow_probability", + ], +) + +py_test( + name = "weibull_test", + size = "small", + srcs = ["weibull_test.py"], + deps = [ + ":bijectors", + # numpy dep, + # six dep, + # tensorflow dep, + "//tensorflow_probability", + ], +) diff --git a/tensorflow_probability/python/bijectors/__init__.py b/tensorflow_probability/python/bijectors/__init__.py new file mode 100644 index 0000000000..9360759357 --- /dev/null +++ b/tensorflow_probability/python/bijectors/__init__.py @@ -0,0 +1,74 @@ +# Copyright 2018 The TensorFlow Probability Authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# ============================================================================ +"""Bijector Ops.""" + +from __future__ import absolute_import +from __future__ import division +from __future__ import print_function + +# pylint: disable=unused-import,wildcard-import,line-too-long,g-importing-member + +from tensorflow_probability.python.bijectors.absolute_value import AbsoluteValue +from tensorflow_probability.python.bijectors.affine import Affine +from tensorflow_probability.python.bijectors.affine_linear_operator import AffineLinearOperator +from tensorflow_probability.python.bijectors.affine_scalar import AffineScalar +from tensorflow_probability.python.bijectors.batch_normalization import BatchNormalization +from tensorflow_probability.python.bijectors.chain import Chain +from tensorflow_probability.python.bijectors.cholesky_outer_product import CholeskyOuterProduct +from tensorflow_probability.python.bijectors.conditional_bijector import ConditionalBijector +from tensorflow_probability.python.bijectors.exp import Exp +from tensorflow_probability.python.bijectors.fill_triangular import FillTriangular +from tensorflow_probability.python.bijectors.gumbel import Gumbel +from tensorflow_probability.python.bijectors.inline import Inline +from tensorflow_probability.python.bijectors.invert import Invert +from tensorflow_probability.python.bijectors.kumaraswamy import Kumaraswamy +from tensorflow_probability.python.bijectors.masked_autoregressive import masked_autoregressive_default_template +from tensorflow_probability.python.bijectors.masked_autoregressive import masked_dense +from tensorflow_probability.python.bijectors.masked_autoregressive import MaskedAutoregressiveFlow +from tensorflow_probability.python.bijectors.matrix_inverse_tril import MatrixInverseTriL +from tensorflow_probability.python.bijectors.permute import Permute +from tensorflow_probability.python.bijectors.power_transform import PowerTransform +from tensorflow_probability.python.bijectors.real_nvp import real_nvp_default_template +from tensorflow_probability.python.bijectors.real_nvp import RealNVP +from tensorflow_probability.python.bijectors.reshape import Reshape +from tensorflow_probability.python.bijectors.scale_tril import ScaleTriL +from tensorflow_probability.python.bijectors.sigmoid import Sigmoid +from tensorflow_probability.python.bijectors.sinh_arcsinh import SinhArcsinh +from tensorflow_probability.python.bijectors.softmax_centered import SoftmaxCentered +from tensorflow_probability.python.bijectors.softplus import Softplus +from tensorflow_probability.python.bijectors.softsign import Softsign +from tensorflow_probability.python.bijectors.square import Square +from tensorflow_probability.python.bijectors.transform_diagonal import TransformDiagonal +from tensorflow_probability.python.bijectors.weibull import Weibull +from tensorflow.python.ops.distributions.bijector import Bijector +from tensorflow.python.ops.distributions.identity_bijector import Identity + +# pylint: enable=unused-import,line-too-long,g-importing-member + +from tensorflow.python.util.all_util import remove_undocumented + +__all__ = [ + "AbsoluteValue", "Affine", "AffineLinearOperator", "AffineScalar", + "Bijector", "BatchNormalization", "Chain", "CholeskyOuterProduct", + "ConditionalBijector", "Exp", "FillTriangular", "Gumbel", "Identity", + "Inline", "Invert", "Kumaraswamy", "MaskedAutoregressiveFlow", + "MatrixInverseTriL", "Permute", "PowerTransform", "RealNVP", "Reshape", + "ScaleTriL", "Sigmoid", "SinhArcsinh", "SoftmaxCentered", "Softplus", + "Softsign", "Square", "TransformDiagonal", "Weibull", + "masked_autoregressive_default_template", "masked_dense", + "real_nvp_default_template" +] + +remove_undocumented(__name__, __all__) diff --git a/tensorflow_probability/python/distributions/bijectors/absolute_value.py b/tensorflow_probability/python/bijectors/absolute_value.py similarity index 100% rename from tensorflow_probability/python/distributions/bijectors/absolute_value.py rename to tensorflow_probability/python/bijectors/absolute_value.py diff --git a/tensorflow_probability/python/distributions/bijectors/absolute_value_test.py b/tensorflow_probability/python/bijectors/absolute_value_test.py similarity index 96% rename from tensorflow_probability/python/distributions/bijectors/absolute_value_test.py rename to tensorflow_probability/python/bijectors/absolute_value_test.py index 4a9f7dc6da..a99be67275 100644 --- a/tensorflow_probability/python/distributions/bijectors/absolute_value_test.py +++ b/tensorflow_probability/python/bijectors/absolute_value_test.py @@ -20,12 +20,9 @@ # pylint: disable=g-importing-member import tensorflow as tf -import tensorflow_probability as tfp - # pylint: enable=g-importing-member -tfd = tfp.distributions -tfb = tfd.bijectors +from tensorflow_probability.python import bijectors as tfb class AbsoluteValueTest(tf.test.TestCase): diff --git a/tensorflow_probability/python/distributions/bijectors/affine.py b/tensorflow_probability/python/bijectors/affine.py similarity index 99% rename from tensorflow_probability/python/distributions/bijectors/affine.py rename to tensorflow_probability/python/bijectors/affine.py index 8a3800f5ae..905b41a53b 100644 --- a/tensorflow_probability/python/distributions/bijectors/affine.py +++ b/tensorflow_probability/python/bijectors/affine.py @@ -19,7 +19,7 @@ from __future__ import print_function import tensorflow as tf -from tensorflow_probability.python.distributions.shape import _DistributionShape +from tensorflow_probability.python.bijectors.shape import _DistributionShape from tensorflow_probability.python.internal import distribution_util from tensorflow.python.framework import tensor_util from tensorflow.python.ops import control_flow_ops diff --git a/tensorflow_probability/python/distributions/bijectors/affine_linear_operator.py b/tensorflow_probability/python/bijectors/affine_linear_operator.py similarity index 98% rename from tensorflow_probability/python/distributions/bijectors/affine_linear_operator.py rename to tensorflow_probability/python/bijectors/affine_linear_operator.py index d673cdefc0..7bc0cde628 100644 --- a/tensorflow_probability/python/distributions/bijectors/affine_linear_operator.py +++ b/tensorflow_probability/python/bijectors/affine_linear_operator.py @@ -19,7 +19,7 @@ from __future__ import print_function import tensorflow as tf -from tensorflow_probability.python.distributions.shape import _DistributionShape +from tensorflow_probability.python.bijectors.shape import _DistributionShape from tensorflow.python.ops.distributions import bijector from tensorflow.python.ops.linalg import linear_operator diff --git a/tensorflow_probability/python/distributions/bijectors/affine_linear_operator_test.py b/tensorflow_probability/python/bijectors/affine_linear_operator_test.py similarity index 98% rename from tensorflow_probability/python/distributions/bijectors/affine_linear_operator_test.py rename to tensorflow_probability/python/bijectors/affine_linear_operator_test.py index e98c964ff6..5eb8a10eb4 100644 --- a/tensorflow_probability/python/distributions/bijectors/affine_linear_operator_test.py +++ b/tensorflow_probability/python/bijectors/affine_linear_operator_test.py @@ -21,10 +21,7 @@ # Dependency imports import numpy as np import tensorflow as tf -import tensorflow_probability as tfp - -tfd = tfp.distributions -tfb = tfd.bijectors +from tensorflow_probability.python import bijectors as tfb class AffineLinearOperatorTest(tf.test.TestCase): diff --git a/tensorflow_probability/python/distributions/bijectors/affine_scalar.py b/tensorflow_probability/python/bijectors/affine_scalar.py similarity index 100% rename from tensorflow_probability/python/distributions/bijectors/affine_scalar.py rename to tensorflow_probability/python/bijectors/affine_scalar.py diff --git a/tensorflow_probability/python/distributions/bijectors/affine_scalar_test.py b/tensorflow_probability/python/bijectors/affine_scalar_test.py similarity index 99% rename from tensorflow_probability/python/distributions/bijectors/affine_scalar_test.py rename to tensorflow_probability/python/bijectors/affine_scalar_test.py index 0b9b68131f..05f772caf2 100644 --- a/tensorflow_probability/python/distributions/bijectors/affine_scalar_test.py +++ b/tensorflow_probability/python/bijectors/affine_scalar_test.py @@ -25,8 +25,7 @@ from tensorflow.python.ops.distributions.bijector_test_util import assert_scalar_congruency -tfd = tfp.distributions -tfb = tfd.bijectors +tfb = tfp.bijectors class AffineScalarBijectorTest(tf.test.TestCase): diff --git a/tensorflow_probability/python/distributions/bijectors/affine_test.py b/tensorflow_probability/python/bijectors/affine_test.py similarity index 99% rename from tensorflow_probability/python/distributions/bijectors/affine_test.py rename to tensorflow_probability/python/bijectors/affine_test.py index 23a1044e19..8500b05c3c 100644 --- a/tensorflow_probability/python/distributions/bijectors/affine_test.py +++ b/tensorflow_probability/python/bijectors/affine_test.py @@ -23,10 +23,7 @@ # Dependency imports import numpy as np import tensorflow as tf -import tensorflow_probability as tfp - -tfd = tfp.distributions -tfb = tfd.bijectors +from tensorflow_probability.python import bijectors as tfb class AffineBijectorTest(tf.test.TestCase): diff --git a/tensorflow_probability/python/distributions/bijectors/batch_normalization.py b/tensorflow_probability/python/bijectors/batch_normalization.py similarity index 100% rename from tensorflow_probability/python/distributions/bijectors/batch_normalization.py rename to tensorflow_probability/python/bijectors/batch_normalization.py diff --git a/tensorflow_probability/python/distributions/bijectors/batch_normalization_test.py b/tensorflow_probability/python/bijectors/batch_normalization_test.py similarity index 99% rename from tensorflow_probability/python/distributions/bijectors/batch_normalization_test.py rename to tensorflow_probability/python/bijectors/batch_normalization_test.py index 0550fcfee9..877517bf91 100644 --- a/tensorflow_probability/python/distributions/bijectors/batch_normalization_test.py +++ b/tensorflow_probability/python/bijectors/batch_normalization_test.py @@ -21,7 +21,7 @@ # Dependency imports import numpy as np import tensorflow as tf -import tensorflow_probability as tfp +from tensorflow_probability.python import bijectors as tfb from tensorflow_probability.python import distributions from tensorflow_probability.python.internal import test_util @@ -29,9 +29,6 @@ from tensorflow.python.ops.distributions import transformed_distribution as transformed_distribution_lib from tensorflow.python.training import adam -tfd = tfp.distributions -tfb = tfd.bijectors - class BatchNormTest(test_util.VectorDistributionTestHelpers, tf.test.TestCase): diff --git a/tensorflow_probability/python/distributions/bijectors/chain.py b/tensorflow_probability/python/bijectors/chain.py similarity index 100% rename from tensorflow_probability/python/distributions/bijectors/chain.py rename to tensorflow_probability/python/bijectors/chain.py diff --git a/tensorflow_probability/python/distributions/bijectors/chain_test.py b/tensorflow_probability/python/bijectors/chain_test.py similarity index 98% rename from tensorflow_probability/python/distributions/bijectors/chain_test.py rename to tensorflow_probability/python/bijectors/chain_test.py index c5edd42d46..dcfd93460f 100644 --- a/tensorflow_probability/python/distributions/bijectors/chain_test.py +++ b/tensorflow_probability/python/bijectors/chain_test.py @@ -21,14 +21,11 @@ # Dependency imports import numpy as np import tensorflow as tf -import tensorflow_probability as tfp +from tensorflow_probability.python import bijectors as tfb from tensorflow.python.ops.distributions import bijector from tensorflow.python.ops.distributions.bijector_test_util import assert_scalar_congruency -tfd = tfp.distributions -tfb = tfd.bijectors - class ShapeChanging(bijector.Bijector): """Only used for op_ndims manipulation.""" diff --git a/tensorflow_probability/python/distributions/bijectors/cholesky_outer_product.py b/tensorflow_probability/python/bijectors/cholesky_outer_product.py similarity index 100% rename from tensorflow_probability/python/distributions/bijectors/cholesky_outer_product.py rename to tensorflow_probability/python/bijectors/cholesky_outer_product.py diff --git a/tensorflow_probability/python/distributions/bijectors/cholesky_outer_product_test.py b/tensorflow_probability/python/bijectors/cholesky_outer_product_test.py similarity index 87% rename from tensorflow_probability/python/distributions/bijectors/cholesky_outer_product_test.py rename to tensorflow_probability/python/bijectors/cholesky_outer_product_test.py index 69c8672e9e..7bbeb98ae8 100644 --- a/tensorflow_probability/python/distributions/bijectors/cholesky_outer_product_test.py +++ b/tensorflow_probability/python/bijectors/cholesky_outer_product_test.py @@ -21,9 +21,7 @@ # Dependency imports import numpy as np import tensorflow as tf -import tensorflow_probability as tfp - -tfd = tfp.distributions +from tensorflow_probability.python import bijectors as tfb class CholeskyOuterProductBijectorTest(tf.test.TestCase): @@ -31,7 +29,7 @@ class CholeskyOuterProductBijectorTest(tf.test.TestCase): def testBijectorMatrix(self): with self.test_session(): - bijector = tfd.bijectors.CholeskyOuterProduct(validate_args=True) + bijector = tfb.CholeskyOuterProduct(validate_args=True) self.assertEqual("cholesky_outer_product", bijector.name) x = [[[1., 0], [2, 1]], [[np.sqrt(2.), 0], [np.sqrt(8.), 1]]] y = np.matmul(x, np.transpose(x, axes=(0, 2, 1))) @@ -63,7 +61,7 @@ def testBijectorMatrix(self): def testNoBatchStaticJacobian(self): x = np.eye(2) - bijector = tfd.bijectors.CholeskyOuterProduct() + bijector = tfb.CholeskyOuterProduct() # The Jacobian matrix is 2 * tf.eye(2), which has jacobian determinant 4. self.assertAllClose( @@ -72,7 +70,7 @@ def testNoBatchStaticJacobian(self): def testNoBatchDynamicJacobian(self): x = np.eye(2) - bijector = tfd.bijectors.CholeskyOuterProduct() + bijector = tfb.CholeskyOuterProduct() x_pl = tf.placeholder(tf.float32) with self.test_session(): @@ -87,8 +85,8 @@ def testNoBatchStatic(self): x = np.array([[1., 0], [2, 1]]) # np.linalg.cholesky(y) y = np.array([[1., 2], [2, 5]]) # np.matmul(x, x.T) with self.test_session() as sess: - y_actual = tfd.bijectors.CholeskyOuterProduct().forward(x=x) - x_actual = tfd.bijectors.CholeskyOuterProduct().inverse(y=y) + y_actual = tfb.CholeskyOuterProduct().forward(x=x) + x_actual = tfb.CholeskyOuterProduct().inverse(y=y) [y_actual_, x_actual_] = sess.run([y_actual, x_actual]) self.assertAllEqual([2, 2], y_actual.get_shape()) self.assertAllEqual([2, 2], x_actual.get_shape()) @@ -101,8 +99,8 @@ def testNoBatchDeferred(self): with self.test_session() as sess: x_pl = tf.placeholder(tf.float32) y_pl = tf.placeholder(tf.float32) - y_actual = tfd.bijectors.CholeskyOuterProduct().forward(x=x_pl) - x_actual = tfd.bijectors.CholeskyOuterProduct().inverse(y=y_pl) + y_actual = tfb.CholeskyOuterProduct().forward(x=x_pl) + x_actual = tfb.CholeskyOuterProduct().inverse(y=y_pl) [y_actual_, x_actual_] = sess.run([y_actual, x_actual], feed_dict={x_pl: x, y_pl: y}) self.assertEqual(None, y_actual.get_shape()) @@ -120,8 +118,8 @@ def testBatchStatic(self): [[9., 3], [3, 5]]]) # np.matmul(x, x.T) with self.test_session() as sess: - y_actual = tfd.bijectors.CholeskyOuterProduct().forward(x=x) - x_actual = tfd.bijectors.CholeskyOuterProduct().inverse(y=y) + y_actual = tfb.CholeskyOuterProduct().forward(x=x) + x_actual = tfb.CholeskyOuterProduct().inverse(y=y) [y_actual_, x_actual_] = sess.run([y_actual, x_actual]) self.assertEqual([2, 2, 2], y_actual.get_shape()) self.assertEqual([2, 2, 2], x_actual.get_shape()) @@ -140,8 +138,8 @@ def testBatchDeferred(self): with self.test_session() as sess: x_pl = tf.placeholder(tf.float32) y_pl = tf.placeholder(tf.float32) - y_actual = tfd.bijectors.CholeskyOuterProduct().forward(x=x_pl) - x_actual = tfd.bijectors.CholeskyOuterProduct().inverse(y=y_pl) + y_actual = tfb.CholeskyOuterProduct().forward(x=x_pl) + x_actual = tfb.CholeskyOuterProduct().inverse(y=y_pl) [y_actual_, x_actual_] = sess.run([y_actual, x_actual], feed_dict={x_pl: x, y_pl: y}) self.assertEqual(None, y_actual.get_shape()) diff --git a/tensorflow_probability/python/distributions/bijectors/conditional_bijector.py b/tensorflow_probability/python/bijectors/conditional_bijector.py similarity index 100% rename from tensorflow_probability/python/distributions/bijectors/conditional_bijector.py rename to tensorflow_probability/python/bijectors/conditional_bijector.py diff --git a/tensorflow_probability/python/distributions/bijectors/conditional_bijector_test.py b/tensorflow_probability/python/bijectors/conditional_bijector_test.py similarity index 96% rename from tensorflow_probability/python/distributions/bijectors/conditional_bijector_test.py rename to tensorflow_probability/python/bijectors/conditional_bijector_test.py index 75e7d53613..b4f6ada562 100644 --- a/tensorflow_probability/python/distributions/bijectors/conditional_bijector_test.py +++ b/tensorflow_probability/python/bijectors/conditional_bijector_test.py @@ -19,10 +19,8 @@ from __future__ import print_function import tensorflow as tf -import tensorflow_probability as tfp -tfd = tfp.distributions -tfb = tfd.bijectors +from tensorflow_probability.python import bijectors as tfb class _TestBijector(tfb.ConditionalBijector): diff --git a/tensorflow_probability/python/distributions/bijectors/exp.py b/tensorflow_probability/python/bijectors/exp.py similarity index 95% rename from tensorflow_probability/python/distributions/bijectors/exp.py rename to tensorflow_probability/python/bijectors/exp.py index 19c0d6bf77..4613bee041 100644 --- a/tensorflow_probability/python/distributions/bijectors/exp.py +++ b/tensorflow_probability/python/bijectors/exp.py @@ -18,7 +18,7 @@ from __future__ import division from __future__ import print_function -from tensorflow_probability.python.distributions.bijectors import power_transform +from tensorflow_probability.python.bijectors import power_transform __all__ = [ diff --git a/tensorflow_probability/python/distributions/bijectors/exp_test.py b/tensorflow_probability/python/bijectors/exp_test.py similarity index 96% rename from tensorflow_probability/python/distributions/bijectors/exp_test.py rename to tensorflow_probability/python/bijectors/exp_test.py index bfff87a874..5c313b9da5 100644 --- a/tensorflow_probability/python/distributions/bijectors/exp_test.py +++ b/tensorflow_probability/python/bijectors/exp_test.py @@ -21,14 +21,11 @@ # Dependency imports import numpy as np import tensorflow as tf -import tensorflow_probability as tfp +from tensorflow_probability.python import bijectors as tfb from tensorflow.python.ops.distributions.bijector_test_util import assert_bijective_and_finite from tensorflow.python.ops.distributions.bijector_test_util import assert_scalar_congruency -tfd = tfp.distributions -tfb = tfd.bijectors - class ExpBijectorTest(tf.test.TestCase): """Tests correctness of the Y = g(X) = exp(X) transformation.""" diff --git a/tensorflow_probability/python/distributions/bijectors/fill_triangular.py b/tensorflow_probability/python/bijectors/fill_triangular.py similarity index 100% rename from tensorflow_probability/python/distributions/bijectors/fill_triangular.py rename to tensorflow_probability/python/bijectors/fill_triangular.py diff --git a/tensorflow_probability/python/distributions/bijectors/fill_triangular_test.py b/tensorflow_probability/python/bijectors/fill_triangular_test.py similarity index 93% rename from tensorflow_probability/python/distributions/bijectors/fill_triangular_test.py rename to tensorflow_probability/python/bijectors/fill_triangular_test.py index cd3afa56de..075debd5cb 100644 --- a/tensorflow_probability/python/distributions/bijectors/fill_triangular_test.py +++ b/tensorflow_probability/python/bijectors/fill_triangular_test.py @@ -21,12 +21,10 @@ # Dependency imports import numpy as np import tensorflow as tf -import tensorflow_probability as tfp +from tensorflow_probability.python import bijectors as tfb from tensorflow.python.framework import test_util -tfd = tfp.distributions - class FillTriangularBijectorTest(tf.test.TestCase): """Tests the correctness of the FillTriangular bijector.""" @@ -37,7 +35,7 @@ def testBijector(self): y = np.float32(np.array([[3., 0.], [2., 1.]])) - b = tfd.bijectors.FillTriangular() + b = tfb.FillTriangular() y_ = self.evaluate(b.forward(x)) self.assertAllClose(y, y_) @@ -56,7 +54,7 @@ def testShape(self): x_shape = tf.TensorShape([5, 4, 6]) y_shape = tf.TensorShape([5, 4, 3, 3]) - b = tfd.bijectors.FillTriangular(validate_args=True) + b = tfb.FillTriangular(validate_args=True) x = tf.ones(shape=x_shape, dtype=tf.float32) y_ = b.forward(x) @@ -79,7 +77,7 @@ def testShape(self): @test_util.run_in_graph_and_eager_modes() def testShapeError(self): - b = tfd.bijectors.FillTriangular(validate_args=True) + b = tfb.FillTriangular(validate_args=True) x_shape_bad = tf.TensorShape([5, 4, 7]) with self.assertRaisesRegexp(ValueError, "is not a triangular number"): diff --git a/tensorflow_probability/python/distributions/bijectors/gumbel.py b/tensorflow_probability/python/bijectors/gumbel.py similarity index 100% rename from tensorflow_probability/python/distributions/bijectors/gumbel.py rename to tensorflow_probability/python/bijectors/gumbel.py diff --git a/tensorflow_probability/python/distributions/bijectors/gumbel_test.py b/tensorflow_probability/python/bijectors/gumbel_test.py similarity index 96% rename from tensorflow_probability/python/distributions/bijectors/gumbel_test.py rename to tensorflow_probability/python/bijectors/gumbel_test.py index 963e186302..0f51c805d9 100644 --- a/tensorflow_probability/python/distributions/bijectors/gumbel_test.py +++ b/tensorflow_probability/python/bijectors/gumbel_test.py @@ -22,14 +22,11 @@ import numpy as np from scipy import stats import tensorflow as tf -import tensorflow_probability as tfp +from tensorflow_probability.python import bijectors as tfb from tensorflow.python.ops.distributions.bijector_test_util import assert_bijective_and_finite from tensorflow.python.ops.distributions.bijector_test_util import assert_scalar_congruency -tfd = tfp.distributions -tfb = tfd.bijectors - class GumbelBijectorTest(tf.test.TestCase): """Tests correctness of the Gumbel bijector.""" diff --git a/tensorflow_probability/python/distributions/bijectors/inline.py b/tensorflow_probability/python/bijectors/inline.py similarity index 100% rename from tensorflow_probability/python/distributions/bijectors/inline.py rename to tensorflow_probability/python/bijectors/inline.py diff --git a/tensorflow_probability/python/distributions/bijectors/inline_test.py b/tensorflow_probability/python/bijectors/inline_test.py similarity index 97% rename from tensorflow_probability/python/distributions/bijectors/inline_test.py rename to tensorflow_probability/python/bijectors/inline_test.py index f82b5f9b82..789413b662 100644 --- a/tensorflow_probability/python/distributions/bijectors/inline_test.py +++ b/tensorflow_probability/python/bijectors/inline_test.py @@ -21,10 +21,7 @@ # Dependency imports import numpy as np import tensorflow as tf -import tensorflow_probability as tfp - -tfd = tfp.distributions -tfb = tfd.bijectors +from tensorflow_probability.python import bijectors as tfb class InlineBijectorTest(tf.test.TestCase): diff --git a/tensorflow_probability/python/distributions/bijectors/invert.py b/tensorflow_probability/python/bijectors/invert.py similarity index 100% rename from tensorflow_probability/python/distributions/bijectors/invert.py rename to tensorflow_probability/python/bijectors/invert.py diff --git a/tensorflow_probability/python/distributions/bijectors/invert_test.py b/tensorflow_probability/python/bijectors/invert_test.py similarity index 84% rename from tensorflow_probability/python/distributions/bijectors/invert_test.py rename to tensorflow_probability/python/bijectors/invert_test.py index 7d4c7e87d2..6ded9977e7 100644 --- a/tensorflow_probability/python/distributions/bijectors/invert_test.py +++ b/tensorflow_probability/python/bijectors/invert_test.py @@ -19,13 +19,12 @@ from __future__ import print_function import tensorflow as tf -import tensorflow_probability as tfp +from tensorflow_probability.python import bijectors as tfb + from tensorflow.python.ops.distributions import gamma as gamma_lib from tensorflow.python.ops.distributions import transformed_distribution as transformed_distribution_lib from tensorflow.python.ops.distributions.bijector_test_util import assert_scalar_congruency -tfd = tfp.distributions - class InvertBijectorTest(tf.test.TestCase): """Tests the correctness of the Y = Invert(bij) transformation.""" @@ -33,13 +32,13 @@ class InvertBijectorTest(tf.test.TestCase): def testBijector(self): with self.test_session(): for fwd in [ - tfd.bijectors.Identity(), - tfd.bijectors.Exp(), - tfd.bijectors.Affine(shift=[0., 1.], scale_diag=[2., 3.]), - tfd.bijectors.Softplus(), - tfd.bijectors.SoftmaxCentered(), + tfb.Identity(), + tfb.Exp(), + tfb.Affine(shift=[0., 1.], scale_diag=[2., 3.]), + tfb.Softplus(), + tfb.SoftmaxCentered(), ]: - rev = tfd.bijectors.Invert(fwd) + rev = tfb.Invert(fwd) self.assertEqual("_".join(["invert", fwd.name]), rev.name) x = [[[1., 2.], [2., 3.]]] @@ -54,14 +53,14 @@ def testBijector(self): def testScalarCongruency(self): with self.test_session(): - bijector = tfd.bijectors.Invert(tfd.bijectors.Exp()) + bijector = tfb.Invert(tfb.Exp()) assert_scalar_congruency( bijector, lower_x=1e-3, upper_x=1.5, rtol=0.05) def testShapeGetters(self): with self.test_session(): - bijector = tfd.bijectors.Invert( - tfd.bijectors.SoftmaxCentered(validate_args=True)) + bijector = tfb.Invert( + tfb.SoftmaxCentered(validate_args=True)) x = tf.TensorShape([2]) y = tf.TensorShape([1]) self.assertAllEqual(y, bijector.forward_event_shape(x)) @@ -78,7 +77,7 @@ def testDocstringExample(self): exp_gamma_distribution = ( transformed_distribution_lib.TransformedDistribution( distribution=gamma_lib.Gamma(concentration=1., rate=2.), - bijector=tfd.bijectors.Invert(tfd.bijectors.Exp()))) + bijector=tfb.Invert(tfb.Exp()))) self.assertAllEqual([], tf.shape(exp_gamma_distribution.sample()).eval()) diff --git a/tensorflow_probability/python/distributions/bijectors/kumaraswamy.py b/tensorflow_probability/python/bijectors/kumaraswamy.py similarity index 100% rename from tensorflow_probability/python/distributions/bijectors/kumaraswamy.py rename to tensorflow_probability/python/bijectors/kumaraswamy.py diff --git a/tensorflow_probability/python/distributions/bijectors/kumaraswamy_bijector_test.py b/tensorflow_probability/python/bijectors/kumaraswamy_bijector_test.py similarity index 97% rename from tensorflow_probability/python/distributions/bijectors/kumaraswamy_bijector_test.py rename to tensorflow_probability/python/bijectors/kumaraswamy_bijector_test.py index f2c89bc70c..aa63974a17 100644 --- a/tensorflow_probability/python/distributions/bijectors/kumaraswamy_bijector_test.py +++ b/tensorflow_probability/python/bijectors/kumaraswamy_bijector_test.py @@ -21,14 +21,11 @@ # Dependency imports import numpy as np import tensorflow as tf -import tensorflow_probability as tfp +from tensorflow_probability.python import bijectors as tfb from tensorflow.python.ops.distributions.bijector_test_util import assert_bijective_and_finite from tensorflow.python.ops.distributions.bijector_test_util import assert_scalar_congruency -tfd = tfp.distributions -tfb = tfd.bijectors - class KumaraswamyBijectorTest(tf.test.TestCase): """Tests correctness of the Kumaraswamy bijector.""" diff --git a/tensorflow_probability/python/distributions/bijectors/masked_autoregressive.py b/tensorflow_probability/python/bijectors/masked_autoregressive.py similarity index 100% rename from tensorflow_probability/python/distributions/bijectors/masked_autoregressive.py rename to tensorflow_probability/python/bijectors/masked_autoregressive.py diff --git a/tensorflow_probability/python/distributions/bijectors/masked_autoregressive_test.py b/tensorflow_probability/python/bijectors/masked_autoregressive_test.py similarity index 96% rename from tensorflow_probability/python/distributions/bijectors/masked_autoregressive_test.py rename to tensorflow_probability/python/bijectors/masked_autoregressive_test.py index 977e400ee5..5958da93d0 100644 --- a/tensorflow_probability/python/distributions/bijectors/masked_autoregressive_test.py +++ b/tensorflow_probability/python/bijectors/masked_autoregressive_test.py @@ -21,15 +21,12 @@ # Dependency imports import numpy as np import tensorflow as tf -import tensorflow_probability as tfp +from tensorflow_probability.python import bijectors as tfb -from tensorflow_probability.python.distributions.bijectors.masked_autoregressive import _gen_mask +from tensorflow_probability.python.bijectors.masked_autoregressive import _gen_mask from tensorflow_probability.python.internal import test_util from tensorflow.python.ops.distributions import transformed_distribution as transformed_distribution_lib -tfd = tfp.distributions -tfb = tfd.bijectors - class GenMaskTest(tf.test.TestCase): diff --git a/tensorflow_probability/python/distributions/bijectors/matrix_inverse_tril.py b/tensorflow_probability/python/bijectors/matrix_inverse_tril.py similarity index 100% rename from tensorflow_probability/python/distributions/bijectors/matrix_inverse_tril.py rename to tensorflow_probability/python/bijectors/matrix_inverse_tril.py diff --git a/tensorflow_probability/python/distributions/bijectors/matrix_inverse_tril_test.py b/tensorflow_probability/python/bijectors/matrix_inverse_tril_test.py similarity index 93% rename from tensorflow_probability/python/distributions/bijectors/matrix_inverse_tril_test.py rename to tensorflow_probability/python/bijectors/matrix_inverse_tril_test.py index 7b107c50c6..95c26bf541 100644 --- a/tensorflow_probability/python/distributions/bijectors/matrix_inverse_tril_test.py +++ b/tensorflow_probability/python/bijectors/matrix_inverse_tril_test.py @@ -21,20 +21,18 @@ # Dependency imports import numpy as np import tensorflow as tf -import tensorflow_probability as tfp +from tensorflow_probability.python import bijectors as tfb from tensorflow.python.framework import errors from tensorflow.python.framework import test_util -tfd = tfp.distributions - class MatrixInverseTriLBijectorTest(tf.test.TestCase): """Tests the correctness of the Y = inv(tril) transformation.""" @test_util.run_in_graph_and_eager_modes() def testComputesCorrectValues(self): - inv = tfd.bijectors.MatrixInverseTriL(validate_args=True) + inv = tfb.MatrixInverseTriL(validate_args=True) self.assertEqual("matrix_inverse_tril", inv.name) x_ = np.array([[0.7, 0., 0.], [0.1, -1., 0.], @@ -56,7 +54,7 @@ def testComputesCorrectValues(self): @test_util.run_in_graph_and_eager_modes() def testOneByOneMatrix(self): - inv = tfd.bijectors.MatrixInverseTriL(validate_args=True) + inv = tfb.MatrixInverseTriL(validate_args=True) x_ = np.array([[5.]], dtype=np.float32) x_inv_ = np.array([[0.2]], dtype=np.float32) expected_fldj_ = np.log(0.04) @@ -75,7 +73,7 @@ def testOneByOneMatrix(self): @test_util.run_in_graph_and_eager_modes() def testZeroByZeroMatrix(self): - inv = tfd.bijectors.MatrixInverseTriL(validate_args=True) + inv = tfb.MatrixInverseTriL(validate_args=True) x_ = np.eye(0, dtype=np.float32) x_inv_ = np.eye(0, dtype=np.float32) expected_fldj_ = 0. @@ -96,7 +94,7 @@ def testZeroByZeroMatrix(self): def testBatch(self): # Test batch computation with input shape (2, 1, 2, 2), i.e. batch shape # (2, 1). - inv = tfd.bijectors.MatrixInverseTriL(validate_args=True) + inv = tfb.MatrixInverseTriL(validate_args=True) x_ = np.array([[[[1., 0.], [2., 3.]]], [[[4., 0.], @@ -119,7 +117,7 @@ def testBatch(self): @test_util.run_in_graph_and_eager_modes() def testErrorOnInputRankTooLow(self): - inv = tfd.bijectors.MatrixInverseTriL(validate_args=True) + inv = tfb.MatrixInverseTriL(validate_args=True) x_ = np.array([0.1], dtype=np.float32) rank_error_msg = "must have rank at least 2" with self.test_session(): @@ -134,7 +132,7 @@ def testErrorOnInputRankTooLow(self): # TODO(b/80481923): Figure out why these assertions fail, and fix them. ## def testErrorOnInputNonSquare(self): - ## inv = tfd.bijectors.MatrixInverseTriL(validate_args=True) + ## inv = tfb.MatrixInverseTriL(validate_args=True) ## x_ = np.array([[1., 2., 3.], ## [4., 5., 6.]], dtype=np.float32) ## square_error_msg = "must be a square matrix" @@ -154,7 +152,7 @@ def testErrorOnInputRankTooLow(self): @test_util.run_in_graph_and_eager_modes() def testErrorOnInputNotLowerTriangular(self): - inv = tfd.bijectors.MatrixInverseTriL(validate_args=True) + inv = tfb.MatrixInverseTriL(validate_args=True) x_ = np.array([[1., 2.], [3., 4.]], dtype=np.float32) triangular_error_msg = "must be lower triangular" @@ -174,7 +172,7 @@ def testErrorOnInputNotLowerTriangular(self): @test_util.run_in_graph_and_eager_modes() def testErrorOnInputSingular(self): - inv = tfd.bijectors.MatrixInverseTriL(validate_args=True) + inv = tfb.MatrixInverseTriL(validate_args=True) x_ = np.array([[1., 0.], [0., 0.]], dtype=np.float32) nonsingular_error_msg = "must have all diagonal entries nonzero" diff --git a/tensorflow_probability/python/distributions/bijectors/ordered.py b/tensorflow_probability/python/bijectors/ordered.py similarity index 100% rename from tensorflow_probability/python/distributions/bijectors/ordered.py rename to tensorflow_probability/python/bijectors/ordered.py diff --git a/tensorflow_probability/python/distributions/bijectors/ordered_test.py b/tensorflow_probability/python/bijectors/ordered_test.py similarity index 100% rename from tensorflow_probability/python/distributions/bijectors/ordered_test.py rename to tensorflow_probability/python/bijectors/ordered_test.py diff --git a/tensorflow_probability/python/distributions/bijectors/permute.py b/tensorflow_probability/python/bijectors/permute.py similarity index 100% rename from tensorflow_probability/python/distributions/bijectors/permute.py rename to tensorflow_probability/python/bijectors/permute.py diff --git a/tensorflow_probability/python/distributions/bijectors/permute_test.py b/tensorflow_probability/python/bijectors/permute_test.py similarity index 97% rename from tensorflow_probability/python/distributions/bijectors/permute_test.py rename to tensorflow_probability/python/bijectors/permute_test.py index 81b014ebf8..45b2b078a4 100644 --- a/tensorflow_probability/python/distributions/bijectors/permute_test.py +++ b/tensorflow_probability/python/bijectors/permute_test.py @@ -21,13 +21,10 @@ # Dependency imports import numpy as np import tensorflow as tf -import tensorflow_probability as tfp +from tensorflow_probability.python import bijectors as tfb from tensorflow.python.ops.distributions.bijector_test_util import assert_bijective_and_finite -tfd = tfp.distributions -tfb = tfd.bijectors - class PermuteBijectorTest(tf.test.TestCase): """Tests correctness of the Permute bijector.""" diff --git a/tensorflow_probability/python/distributions/bijectors/power_transform.py b/tensorflow_probability/python/bijectors/power_transform.py similarity index 100% rename from tensorflow_probability/python/distributions/bijectors/power_transform.py rename to tensorflow_probability/python/bijectors/power_transform.py diff --git a/tensorflow_probability/python/distributions/bijectors/power_transform_test.py b/tensorflow_probability/python/bijectors/power_transform_test.py similarity index 96% rename from tensorflow_probability/python/distributions/bijectors/power_transform_test.py rename to tensorflow_probability/python/bijectors/power_transform_test.py index 2769958a59..6f096fa215 100644 --- a/tensorflow_probability/python/distributions/bijectors/power_transform_test.py +++ b/tensorflow_probability/python/bijectors/power_transform_test.py @@ -21,14 +21,11 @@ # Dependency imports import numpy as np import tensorflow as tf -import tensorflow_probability as tfp +from tensorflow_probability.python import bijectors as tfb from tensorflow.python.ops.distributions.bijector_test_util import assert_bijective_and_finite from tensorflow.python.ops.distributions.bijector_test_util import assert_scalar_congruency -tfd = tfp.distributions -tfb = tfd.bijectors - class PowerTransformBijectorTest(tf.test.TestCase): """Tests correctness of the power transformation.""" diff --git a/tensorflow_probability/python/distributions/bijectors/real_nvp.py b/tensorflow_probability/python/bijectors/real_nvp.py similarity index 100% rename from tensorflow_probability/python/distributions/bijectors/real_nvp.py rename to tensorflow_probability/python/bijectors/real_nvp.py diff --git a/tensorflow_probability/python/distributions/bijectors/real_nvp_test.py b/tensorflow_probability/python/bijectors/real_nvp_test.py similarity index 98% rename from tensorflow_probability/python/distributions/bijectors/real_nvp_test.py rename to tensorflow_probability/python/bijectors/real_nvp_test.py index 2906a7cdb7..3023300646 100644 --- a/tensorflow_probability/python/distributions/bijectors/real_nvp_test.py +++ b/tensorflow_probability/python/bijectors/real_nvp_test.py @@ -21,13 +21,10 @@ # Dependency imports import numpy as np import tensorflow as tf -import tensorflow_probability as tfp +from tensorflow_probability.python import bijectors as tfb from tensorflow_probability.python.internal import test_util from tensorflow.python.ops.distributions import transformed_distribution as transformed_distribution_lib -tfd = tfp.distributions -tfb = tfd.bijectors - class RealNVPTest(test_util.VectorDistributionTestHelpers, tf.test.TestCase): diff --git a/tensorflow_probability/python/distributions/bijectors/reshape.py b/tensorflow_probability/python/bijectors/reshape.py similarity index 100% rename from tensorflow_probability/python/distributions/bijectors/reshape.py rename to tensorflow_probability/python/bijectors/reshape.py diff --git a/tensorflow_probability/python/distributions/bijectors/reshape_test.py b/tensorflow_probability/python/bijectors/reshape_test.py similarity index 99% rename from tensorflow_probability/python/distributions/bijectors/reshape_test.py rename to tensorflow_probability/python/bijectors/reshape_test.py index 3c36c1c6d0..00284ae07a 100644 --- a/tensorflow_probability/python/distributions/bijectors/reshape_test.py +++ b/tensorflow_probability/python/bijectors/reshape_test.py @@ -21,13 +21,10 @@ # Dependency imports import numpy as np import tensorflow as tf -import tensorflow_probability as tfp +from tensorflow_probability.python import bijectors as tfb from tensorflow.python.ops.distributions.bijector_test_util import assert_bijective_and_finite -tfd = tfp.distributions -tfb = tfd.bijectors - class _ReshapeBijectorTest(object): """Base class for testing the reshape transformation. diff --git a/tensorflow_probability/python/distributions/bijectors/scale_tril.py b/tensorflow_probability/python/bijectors/scale_tril.py similarity index 90% rename from tensorflow_probability/python/distributions/bijectors/scale_tril.py rename to tensorflow_probability/python/bijectors/scale_tril.py index 5c41e99091..f2f91821c7 100644 --- a/tensorflow_probability/python/distributions/bijectors/scale_tril.py +++ b/tensorflow_probability/python/bijectors/scale_tril.py @@ -18,11 +18,11 @@ from __future__ import division from __future__ import print_function -from tensorflow_probability.python.distributions.bijectors import affine_scalar -from tensorflow_probability.python.distributions.bijectors import chain -from tensorflow_probability.python.distributions.bijectors import fill_triangular -from tensorflow_probability.python.distributions.bijectors import softplus -from tensorflow_probability.python.distributions.bijectors import transform_diagonal +from tensorflow_probability.python.bijectors import affine_scalar +from tensorflow_probability.python.bijectors import chain +from tensorflow_probability.python.bijectors import fill_triangular +from tensorflow_probability.python.bijectors import softplus +from tensorflow_probability.python.bijectors import transform_diagonal __all__ = [ "ScaleTriL", diff --git a/tensorflow_probability/python/distributions/bijectors/scale_tril_test.py b/tensorflow_probability/python/bijectors/scale_tril_test.py similarity index 89% rename from tensorflow_probability/python/distributions/bijectors/scale_tril_test.py rename to tensorflow_probability/python/bijectors/scale_tril_test.py index 451857c805..651c94a9a7 100644 --- a/tensorflow_probability/python/distributions/bijectors/scale_tril_test.py +++ b/tensorflow_probability/python/bijectors/scale_tril_test.py @@ -21,12 +21,10 @@ # Dependency imports import numpy as np import tensorflow as tf -import tensorflow_probability as tfp +from tensorflow_probability.python import bijectors as tfb from tensorflow.python.framework import test_util -tfd = tfp.distributions - class ScaleTriLBijectorTest(tf.test.TestCase): """Tests the correctness of the ScaleTriL bijector.""" @@ -40,8 +38,8 @@ def testComputesCorrectValues(self): y = np.float32(np.array([[np.exp(2) + shift, 0.], [.5, np.exp(-1) + shift]])) - b = tfd.bijectors.ScaleTriL( - diag_bijector=tfd.bijectors.Exp(), diag_shift=shift) + b = tfb.ScaleTriL( + diag_bijector=tfb.Exp(), diag_shift=shift) y_ = self.evaluate(b.forward(x)) self.assertAllClose(y, y_) @@ -56,8 +54,8 @@ def testInvertible(self): # event size 6 to specify 3x3 triangular matrices. batch_shape = [2, 1] x = np.float32(np.random.randn(*(batch_shape + [6]))) - b = tfd.bijectors.ScaleTriL( - diag_bijector=tfd.bijectors.Softplus(), diag_shift=3.14159) + b = tfb.ScaleTriL( + diag_bijector=tfb.Softplus(), diag_shift=3.14159) y = self.evaluate(b.forward(x)) self.assertAllEqual(y.shape, batch_shape + [3, 3]) diff --git a/tensorflow_probability/python/distributions/shape.py b/tensorflow_probability/python/bijectors/shape.py similarity index 100% rename from tensorflow_probability/python/distributions/shape.py rename to tensorflow_probability/python/bijectors/shape.py diff --git a/tensorflow_probability/python/distributions/shape_test.py b/tensorflow_probability/python/bijectors/shape_test.py similarity index 99% rename from tensorflow_probability/python/distributions/shape_test.py rename to tensorflow_probability/python/bijectors/shape_test.py index a61aa3cea4..7bd471546c 100644 --- a/tensorflow_probability/python/distributions/shape_test.py +++ b/tensorflow_probability/python/bijectors/shape_test.py @@ -22,7 +22,7 @@ import numpy as np import tensorflow as tf -from tensorflow_probability.python.distributions.shape import _DistributionShape +from tensorflow_probability.python.bijectors.shape import _DistributionShape from tensorflow.python.framework import tensor_util _empty_shape = np.array([], dtype=np.int32) diff --git a/tensorflow_probability/python/distributions/bijectors/sigmoid.py b/tensorflow_probability/python/bijectors/sigmoid.py similarity index 100% rename from tensorflow_probability/python/distributions/bijectors/sigmoid.py rename to tensorflow_probability/python/bijectors/sigmoid.py diff --git a/tensorflow_probability/python/distributions/bijectors/sigmoid_test.py b/tensorflow_probability/python/bijectors/sigmoid_test.py similarity index 96% rename from tensorflow_probability/python/distributions/bijectors/sigmoid_test.py rename to tensorflow_probability/python/bijectors/sigmoid_test.py index 68d793874f..1362b97048 100644 --- a/tensorflow_probability/python/distributions/bijectors/sigmoid_test.py +++ b/tensorflow_probability/python/bijectors/sigmoid_test.py @@ -22,14 +22,11 @@ import numpy as np from scipy import special import tensorflow as tf -import tensorflow_probability as tfp +from tensorflow_probability.python import bijectors as tfb from tensorflow.python.ops.distributions.bijector_test_util import assert_bijective_and_finite from tensorflow.python.ops.distributions.bijector_test_util import assert_scalar_congruency -tfd = tfp.distributions -tfb = tfd.bijectors - class SigmoidBijectorTest(tf.test.TestCase): """Tests correctness of the Y = g(X) = (1 + exp(-X))^-1 transformation.""" diff --git a/tensorflow_probability/python/distributions/bijectors/sinh_arcsinh.py b/tensorflow_probability/python/bijectors/sinh_arcsinh.py similarity index 100% rename from tensorflow_probability/python/distributions/bijectors/sinh_arcsinh.py rename to tensorflow_probability/python/bijectors/sinh_arcsinh.py diff --git a/tensorflow_probability/python/distributions/bijectors/sinh_arcsinh_bijector_test.py b/tensorflow_probability/python/bijectors/sinh_arcsinh_bijector_test.py similarity index 98% rename from tensorflow_probability/python/distributions/bijectors/sinh_arcsinh_bijector_test.py rename to tensorflow_probability/python/bijectors/sinh_arcsinh_bijector_test.py index 5babd7515d..9944663bcb 100644 --- a/tensorflow_probability/python/distributions/bijectors/sinh_arcsinh_bijector_test.py +++ b/tensorflow_probability/python/bijectors/sinh_arcsinh_bijector_test.py @@ -21,7 +21,7 @@ # Dependency imports import numpy as np import tensorflow as tf -import tensorflow_probability as tfp +from tensorflow_probability.python import bijectors as tfb # pylint: disable=g-importing-member from tensorflow.python.ops.distributions.bijector_test_util import assert_bijective_and_finite @@ -29,9 +29,6 @@ # pylint: enable=g-importing-member -tfd = tfp.distributions -tfb = tfd.bijectors - class SinhArcsinhBijectorTest(tf.test.TestCase): """Tests correctness of the power transformation.""" diff --git a/tensorflow_probability/python/distributions/bijectors/softmax_centered.py b/tensorflow_probability/python/bijectors/softmax_centered.py similarity index 100% rename from tensorflow_probability/python/distributions/bijectors/softmax_centered.py rename to tensorflow_probability/python/bijectors/softmax_centered.py diff --git a/tensorflow_probability/python/distributions/bijectors/softmax_centered_test.py b/tensorflow_probability/python/bijectors/softmax_centered_test.py similarity index 98% rename from tensorflow_probability/python/distributions/bijectors/softmax_centered_test.py rename to tensorflow_probability/python/bijectors/softmax_centered_test.py index 1e6ed73564..5eaeab1406 100644 --- a/tensorflow_probability/python/distributions/bijectors/softmax_centered_test.py +++ b/tensorflow_probability/python/bijectors/softmax_centered_test.py @@ -21,13 +21,10 @@ # Dependency imports import numpy as np import tensorflow as tf -import tensorflow_probability as tfp +from tensorflow_probability.python import bijectors as tfb from tensorflow.python.ops.distributions.bijector_test_util import assert_bijective_and_finite -tfd = tfp.distributions -tfb = tfd.bijectors - rng = np.random.RandomState(42) diff --git a/tensorflow_probability/python/distributions/bijectors/softplus.py b/tensorflow_probability/python/bijectors/softplus.py similarity index 100% rename from tensorflow_probability/python/distributions/bijectors/softplus.py rename to tensorflow_probability/python/bijectors/softplus.py diff --git a/tensorflow_probability/python/distributions/bijectors/softplus_test.py b/tensorflow_probability/python/bijectors/softplus_test.py similarity index 98% rename from tensorflow_probability/python/distributions/bijectors/softplus_test.py rename to tensorflow_probability/python/bijectors/softplus_test.py index f6c8bee1bc..33dc746f4e 100644 --- a/tensorflow_probability/python/distributions/bijectors/softplus_test.py +++ b/tensorflow_probability/python/bijectors/softplus_test.py @@ -21,14 +21,11 @@ # Dependency imports import numpy as np import tensorflow as tf -import tensorflow_probability as tfp +from tensorflow_probability.python import bijectors as tfb from tensorflow.python.ops.distributions.bijector_test_util import assert_bijective_and_finite from tensorflow.python.ops.distributions.bijector_test_util import assert_scalar_congruency -tfd = tfp.distributions -tfb = tfd.bijectors - rng = np.random.RandomState(42) diff --git a/tensorflow_probability/python/distributions/bijectors/softsign.py b/tensorflow_probability/python/bijectors/softsign.py similarity index 100% rename from tensorflow_probability/python/distributions/bijectors/softsign.py rename to tensorflow_probability/python/bijectors/softsign.py diff --git a/tensorflow_probability/python/distributions/bijectors/softsign_test.py b/tensorflow_probability/python/bijectors/softsign_test.py similarity index 98% rename from tensorflow_probability/python/distributions/bijectors/softsign_test.py rename to tensorflow_probability/python/bijectors/softsign_test.py index 206b8fd6c1..d56d698429 100644 --- a/tensorflow_probability/python/distributions/bijectors/softsign_test.py +++ b/tensorflow_probability/python/bijectors/softsign_test.py @@ -21,15 +21,12 @@ # Dependency imports import numpy as np import tensorflow as tf -import tensorflow_probability as tfp +from tensorflow_probability.python import bijectors as tfb from tensorflow.python.framework import test_util from tensorflow.python.ops.distributions.bijector_test_util import assert_bijective_and_finite from tensorflow.python.ops.distributions.bijector_test_util import assert_scalar_congruency -tfd = tfp.distributions -tfb = tfd.bijectors - class SoftsignBijectorTest(tf.test.TestCase): """Tests the correctness of the Y = g(X) = X / (1 + |X|) transformation.""" diff --git a/tensorflow_probability/python/distributions/bijectors/square.py b/tensorflow_probability/python/bijectors/square.py similarity index 100% rename from tensorflow_probability/python/distributions/bijectors/square.py rename to tensorflow_probability/python/bijectors/square.py diff --git a/tensorflow_probability/python/distributions/bijectors/square_test.py b/tensorflow_probability/python/bijectors/square_test.py similarity index 91% rename from tensorflow_probability/python/distributions/bijectors/square_test.py rename to tensorflow_probability/python/bijectors/square_test.py index 3286cdd212..d75f6759cd 100644 --- a/tensorflow_probability/python/distributions/bijectors/square_test.py +++ b/tensorflow_probability/python/bijectors/square_test.py @@ -21,19 +21,17 @@ # Dependency imports import numpy as np import tensorflow as tf -import tensorflow_probability as tfp +from tensorflow_probability.python import bijectors as tfb from tensorflow.python.ops.distributions.bijector_test_util import assert_scalar_congruency -tfd = tfp.distributions - class SquareBijectorTest(tf.test.TestCase): """Tests the correctness of the Y = X ** 2 transformation.""" def testBijectorScalar(self): with self.test_session(): - bijector = tfd.bijectors.Square(validate_args=True) + bijector = tfb.Square(validate_args=True) self.assertEqual("square", bijector.name) x = [[[1., 5], [2, 1]], @@ -54,7 +52,7 @@ def testBijectorScalar(self): def testScalarCongruency(self): with self.test_session(): - bijector = tfd.bijectors.Square(validate_args=True) + bijector = tfb.Square(validate_args=True) assert_scalar_congruency(bijector, lower_x=1e-3, upper_x=1.5, rtol=0.05) diff --git a/tensorflow_probability/python/distributions/bijectors/transform_diagonal.py b/tensorflow_probability/python/bijectors/transform_diagonal.py similarity index 100% rename from tensorflow_probability/python/distributions/bijectors/transform_diagonal.py rename to tensorflow_probability/python/bijectors/transform_diagonal.py diff --git a/tensorflow_probability/python/distributions/bijectors/transform_diagonal_test.py b/tensorflow_probability/python/bijectors/transform_diagonal_test.py similarity index 93% rename from tensorflow_probability/python/distributions/bijectors/transform_diagonal_test.py rename to tensorflow_probability/python/bijectors/transform_diagonal_test.py index fa6c356929..145eb988db 100644 --- a/tensorflow_probability/python/distributions/bijectors/transform_diagonal_test.py +++ b/tensorflow_probability/python/bijectors/transform_diagonal_test.py @@ -21,12 +21,10 @@ # Dependency imports import numpy as np import tensorflow as tf -import tensorflow_probability as tfp +from tensorflow_probability.python import bijectors as tfb from tensorflow.python.framework import test_util -tfd = tfp.distributions - class TransformDiagonalBijectorTest(tf.test.TestCase): """Tests correctness of the TransformDiagonal bijector.""" @@ -42,8 +40,8 @@ def testBijector(self): for i in range(x.shape[0]): np.fill_diagonal(y[i, :, :], np.exp(np.diag(x[i, :, :]))) - exp = tfd.bijectors.Exp() - b = tfd.bijectors.TransformDiagonal(diag_bijector=exp) + exp = tfb.Exp() + b = tfb.TransformDiagonal(diag_bijector=exp) y_ = self.evaluate(b.forward(x)) self.assertAllClose(y, y_) diff --git a/tensorflow_probability/python/distributions/bijectors/weibull.py b/tensorflow_probability/python/bijectors/weibull.py similarity index 100% rename from tensorflow_probability/python/distributions/bijectors/weibull.py rename to tensorflow_probability/python/bijectors/weibull.py diff --git a/tensorflow_probability/python/distributions/bijectors/weibull_test.py b/tensorflow_probability/python/bijectors/weibull_test.py similarity index 97% rename from tensorflow_probability/python/distributions/bijectors/weibull_test.py rename to tensorflow_probability/python/bijectors/weibull_test.py index 291647c295..353a985ac6 100644 --- a/tensorflow_probability/python/distributions/bijectors/weibull_test.py +++ b/tensorflow_probability/python/bijectors/weibull_test.py @@ -22,14 +22,11 @@ import numpy as np from scipy import stats import tensorflow as tf -import tensorflow_probability as tfp +from tensorflow_probability.python import bijectors as tfb from tensorflow.python.ops.distributions.bijector_test_util import assert_bijective_and_finite from tensorflow.python.ops.distributions.bijector_test_util import assert_scalar_congruency -tfd = tfp.distributions -tfb = tfd.bijectors - class WeibullBijectorTest(tf.test.TestCase): """Tests correctness of the weibull bijector.""" diff --git a/tensorflow_probability/python/distributions/BUILD b/tensorflow_probability/python/distributions/BUILD index 8c2f466585..bec297cf44 100644 --- a/tensorflow_probability/python/distributions/BUILD +++ b/tensorflow_probability/python/distributions/BUILD @@ -26,20 +26,6 @@ package( exports_files(["LICENSE"]) -py_library( - name = "bijectors", - srcs = glob( - ["bijectors/*.py"], - exclude = glob(["bijectors/*_test.py"]), - ), - srcs_version = "PY2AND3", - deps = [ - # numpy dep, - # tensorflow dep, - "//tensorflow_probability/python/internal:distribution_util", - ], -) - py_library( name = "distributions", srcs = glob( @@ -54,10 +40,10 @@ py_library( ), srcs_version = "PY2AND3", deps = [ - ":bijectors", # numpy dep, # six dep, # tensorflow dep, + "//tensorflow_probability/python/bijectors", "//tensorflow_probability/python/internal:distribution_util", ], ) @@ -560,7 +546,6 @@ py_test( size = "medium", srcs = ["transformed_distribution_test.py"], deps = [ - ":bijectors", ":distributions", # numpy dep, # tensorflow dep, @@ -596,424 +581,3 @@ py_test( "//tensorflow_probability", ], ) - -py_test( - name = "shape_test", - size = "medium", - srcs = ["shape_test.py"], - deps = [ - ":distributions", - # numpy dep, - # tensorflow dep, - "//tensorflow_probability", - ], -) - -# === Bijector Tests ========================================================== - -py_test( - name = "conditional_bijector_test", - size = "small", - srcs = ["bijectors/conditional_bijector_test.py"], - deps = [ - ":bijectors", - ":distributions", - # numpy dep, - # six dep, - # tensorflow dep, - "//tensorflow_probability", - ], -) - -py_test( - name = "absolute_value_test", - size = "small", - srcs = ["bijectors/absolute_value_test.py"], - deps = [ - ":bijectors", - ":distributions", - # numpy dep, - # six dep, - # tensorflow dep, - "//tensorflow_probability", - ], -) - -py_test( - name = "affine_test", - size = "large", - srcs = ["bijectors/affine_test.py"], - shard_count = 5, - tags = ["noasan"], # times out b/63678675 - deps = [ - ":bijectors", - ":distributions", - # numpy dep, - # six dep, - # tensorflow dep, - "//tensorflow_probability", - ], -) - -py_test( - name = "affine_scalar_test", - size = "small", - srcs = ["bijectors/affine_scalar_test.py"], - deps = [ - ":bijectors", - ":distributions", - # numpy dep, - # six dep, - # tensorflow dep, - "//tensorflow_probability", - ], -) - -py_test( - name = "affine_linear_operator_test", - size = "small", - srcs = ["bijectors/affine_linear_operator_test.py"], - deps = [ - ":bijectors", - ":distributions", - # numpy dep, - # six dep, - # tensorflow dep, - "//tensorflow_probability", - ], -) - -py_test( - name = "batch_normalization_test", - size = "small", - srcs = ["bijectors/batch_normalization_test.py"], - deps = [ - ":bijectors", - ":distributions", - # numpy dep, - # tensorflow dep, - "//tensorflow_probability", - "//tensorflow_probability/python/internal:test_util", - ], -) - -py_test( - name = "chain_test", - size = "small", - srcs = ["bijectors/chain_test.py"], - deps = [ - ":bijectors", - ":distributions", - # numpy dep, - # six dep, - # tensorflow dep, - "//tensorflow_probability", - ], -) - -py_test( - name = "cholesky_outer_product_test", - size = "small", - srcs = ["bijectors/cholesky_outer_product_test.py"], - deps = [ - ":bijectors", - ":distributions", - # numpy dep, - # six dep, - # tensorflow dep, - "//tensorflow_probability", - ], -) - -py_test( - name = "exp_test", - size = "small", - srcs = ["bijectors/exp_test.py"], - deps = [ - ":bijectors", - ":distributions", - # numpy dep, - # six dep, - # tensorflow dep, - "//tensorflow_probability", - ], -) - -py_test( - name = "fill_triangular_test", - size = "small", - srcs = ["bijectors/fill_triangular_test.py"], - deps = [ - ":bijectors", - ":distributions", - # numpy dep, - # six dep, - # tensorflow dep, - "//tensorflow_probability", - ], -) - -py_test( - name = "gumbel_test", - size = "small", - srcs = ["bijectors/gumbel_test.py"], - deps = [ - ":bijectors", - ":distributions", - # numpy dep, - # six dep, - # tensorflow dep, - "//tensorflow_probability", - ], -) - -py_test( - name = "inline_test", - size = "small", - srcs = ["bijectors/inline_test.py"], - deps = [ - ":bijectors", - ":distributions", - # numpy dep, - # six dep, - # tensorflow dep, - "//tensorflow_probability", - ], -) - -py_test( - name = "invert_test", - size = "small", - srcs = ["bijectors/invert_test.py"], - deps = [ - ":bijectors", - ":distributions", - # numpy dep, - # six dep, - # tensorflow dep, - "//tensorflow_probability", - ], -) - -py_test( - name = "kumaraswamy_bijector_test", - size = "small", - srcs = ["bijectors/kumaraswamy_bijector_test.py"], - deps = [ - ":bijectors", - ":distributions", - # numpy dep, - # six dep, - # tensorflow dep, - "//tensorflow_probability", - ], -) - -py_test( - name = "masked_autoregressive_test", - size = "small", - srcs = ["bijectors/masked_autoregressive_test.py"], - deps = [ - ":bijectors", - ":distributions", - # numpy dep, - # tensorflow dep, - "//tensorflow_probability", - "//tensorflow_probability/python/internal:test_util", - ], -) - -py_test( - name = "matrix_inverse_tril_test", - size = "small", - srcs = ["bijectors/matrix_inverse_tril_test.py"], - deps = [ - ":bijectors", - ":distributions", - # numpy dep, - # tensorflow dep, - "//tensorflow_probability", - ], -) - -py_test( - name = "real_nvp_test", - size = "small", - srcs = ["bijectors/real_nvp_test.py"], - deps = [ - ":bijectors", - ":distributions", - # numpy dep, - # tensorflow dep, - "//tensorflow_probability", - "//tensorflow_probability/python/internal:test_util", - ], -) - -py_test( - name = "permute_test", - size = "small", - srcs = ["bijectors/permute_test.py"], - deps = [ - ":bijectors", - ":distributions", - # numpy dep, - # tensorflow dep, - "//tensorflow_probability", - ], -) - -py_test( - name = "power_transform_test", - size = "small", - srcs = ["bijectors/power_transform_test.py"], - deps = [ - ":bijectors", - ":distributions", - # numpy dep, - # six dep, - # tensorflow dep, - "//tensorflow_probability", - ], -) - -py_test( - name = "reshape_test", - size = "medium", - srcs = ["bijectors/reshape_test.py"], - deps = [ - ":bijectors", - ":distributions", - # numpy dep, - # tensorflow dep, - "//tensorflow_probability", - ], -) - -py_test( - name = "scale_tril_test", - size = "medium", - srcs = ["bijectors/scale_tril_test.py"], - deps = [ - ":bijectors", - ":distributions", - # numpy dep, - # tensorflow dep, - "//tensorflow_probability", - ], -) - -py_test( - name = "sigmoid_test", - size = "small", - srcs = ["bijectors/sigmoid_test.py"], - deps = [ - ":bijectors", - ":distributions", - # numpy dep, - # six dep, - # tensorflow dep, - "//tensorflow_probability", - ], -) - -# Tests for SinhArcSinh bijector. The file name has the extra "_bijector" to -# avoid BUILD rule name conflicts with the distribution by the same name. -py_test( - name = "sinh_arcsinh_bijector_test", - size = "small", - srcs = ["bijectors/sinh_arcsinh_bijector_test.py"], - tags = ["no_windows"], # TODO: needs investigation on Windows - deps = [ - ":bijectors", - ":distributions", - # numpy dep, - # six dep, - # tensorflow dep, - "//tensorflow_probability", - ], -) - -py_test( - name = "softmax_centered_test", - size = "small", - srcs = ["bijectors/softmax_centered_test.py"], - deps = [ - ":bijectors", - ":distributions", - # numpy dep, - # six dep, - # tensorflow dep, - "//tensorflow_probability", - ], -) - -py_test( - name = "softplus_test", - size = "small", - srcs = ["bijectors/softplus_test.py"], - deps = [ - ":bijectors", - ":distributions", - # numpy dep, - # six dep, - # tensorflow dep, - "//tensorflow_probability", - ], -) - -py_test( - name = "softsign_test", - size = "small", - srcs = ["bijectors/softsign_test.py"], - deps = [ - ":bijectors", - ":distributions", - # numpy dep, - # six dep, - # tensorflow dep, - "//tensorflow_probability", - ], -) - -py_test( - name = "square_test", - size = "small", - srcs = ["bijectors/square_test.py"], - deps = [ - ":bijectors", - ":distributions", - # numpy dep, - # six dep, - # tensorflow dep, - "//tensorflow_probability", - ], -) - -py_test( - name = "transform_diagonal_test", - size = "small", - srcs = ["bijectors/transform_diagonal_test.py"], - deps = [ - ":bijectors", - ":distributions", - # numpy dep, - # six dep, - # tensorflow dep, - "//tensorflow_probability", - ], -) - -py_test( - name = "weibull_test", - size = "small", - srcs = ["bijectors/weibull_test.py"], - deps = [ - ":bijectors", - ":distributions", - # numpy dep, - # six dep, - # tensorflow dep, - "//tensorflow_probability", - ], -) diff --git a/tensorflow_probability/python/distributions/__init__.py b/tensorflow_probability/python/distributions/__init__.py index 54755a459a..19288ff36e 100644 --- a/tensorflow_probability/python/distributions/__init__.py +++ b/tensorflow_probability/python/distributions/__init__.py @@ -19,8 +19,6 @@ # pylint: disable=unused-import,line-too-long,g-importing-member -from tensorflow_probability.python.distributions import bijectors - from tensorflow_probability.python.distributions.autoregressive import Autoregressive from tensorflow_probability.python.distributions.batch_reshape import BatchReshape from tensorflow_probability.python.distributions.binomial import Binomial @@ -115,7 +113,6 @@ __all__ = [ 'auto_correlation', - 'bijectors', 'Cauchy', 'ConditionalDistribution', 'ConditionalTransformedDistribution', diff --git a/tensorflow_probability/python/distributions/autoregressive_test.py b/tensorflow_probability/python/distributions/autoregressive_test.py index b00253536d..6f5f48f801 100644 --- a/tensorflow_probability/python/distributions/autoregressive_test.py +++ b/tensorflow_probability/python/distributions/autoregressive_test.py @@ -26,7 +26,7 @@ from tensorflow.python.ops.distributions import util as distribution_util tfd = tfp.distributions -tfb = tfd.bijectors +tfb = tfp.bijectors class AutogressiveTest(test_util.VectorDistributionTestHelpers, diff --git a/tensorflow_probability/python/distributions/bijectors/__init__.py b/tensorflow_probability/python/distributions/bijectors/__init__.py deleted file mode 100644 index 4c23127df7..0000000000 --- a/tensorflow_probability/python/distributions/bijectors/__init__.py +++ /dev/null @@ -1,74 +0,0 @@ -# Copyright 2018 The TensorFlow Probability Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# ============================================================================ -"""Bijector Ops.""" - -from __future__ import absolute_import -from __future__ import division -from __future__ import print_function - -# pylint: disable=unused-import,wildcard-import,line-too-long,g-importing-member - -from tensorflow_probability.python.distributions.bijectors.absolute_value import AbsoluteValue -from tensorflow_probability.python.distributions.bijectors.affine import Affine -from tensorflow_probability.python.distributions.bijectors.affine_linear_operator import AffineLinearOperator -from tensorflow_probability.python.distributions.bijectors.affine_scalar import AffineScalar -from tensorflow_probability.python.distributions.bijectors.batch_normalization import BatchNormalization -from tensorflow_probability.python.distributions.bijectors.chain import Chain -from tensorflow_probability.python.distributions.bijectors.cholesky_outer_product import CholeskyOuterProduct -from tensorflow_probability.python.distributions.bijectors.conditional_bijector import ConditionalBijector -from tensorflow_probability.python.distributions.bijectors.exp import Exp -from tensorflow_probability.python.distributions.bijectors.fill_triangular import FillTriangular -from tensorflow_probability.python.distributions.bijectors.gumbel import Gumbel -from tensorflow_probability.python.distributions.bijectors.inline import Inline -from tensorflow_probability.python.distributions.bijectors.invert import Invert -from tensorflow_probability.python.distributions.bijectors.kumaraswamy import Kumaraswamy -from tensorflow_probability.python.distributions.bijectors.masked_autoregressive import masked_autoregressive_default_template -from tensorflow_probability.python.distributions.bijectors.masked_autoregressive import masked_dense -from tensorflow_probability.python.distributions.bijectors.masked_autoregressive import MaskedAutoregressiveFlow -from tensorflow_probability.python.distributions.bijectors.matrix_inverse_tril import MatrixInverseTriL -from tensorflow_probability.python.distributions.bijectors.permute import Permute -from tensorflow_probability.python.distributions.bijectors.power_transform import PowerTransform -from tensorflow_probability.python.distributions.bijectors.real_nvp import real_nvp_default_template -from tensorflow_probability.python.distributions.bijectors.real_nvp import RealNVP -from tensorflow_probability.python.distributions.bijectors.reshape import Reshape -from tensorflow_probability.python.distributions.bijectors.scale_tril import ScaleTriL -from tensorflow_probability.python.distributions.bijectors.sigmoid import Sigmoid -from tensorflow_probability.python.distributions.bijectors.sinh_arcsinh import SinhArcsinh -from tensorflow_probability.python.distributions.bijectors.softmax_centered import SoftmaxCentered -from tensorflow_probability.python.distributions.bijectors.softplus import Softplus -from tensorflow_probability.python.distributions.bijectors.softsign import Softsign -from tensorflow_probability.python.distributions.bijectors.square import Square -from tensorflow_probability.python.distributions.bijectors.transform_diagonal import TransformDiagonal -from tensorflow_probability.python.distributions.bijectors.weibull import Weibull -from tensorflow.python.ops.distributions.bijector import Bijector -from tensorflow.python.ops.distributions.identity_bijector import Identity - -# pylint: enable=unused-import,line-too-long,g-importing-member - -from tensorflow.python.util.all_util import remove_undocumented - -__all__ = [ - "AbsoluteValue", "Affine", "AffineLinearOperator", "AffineScalar", - "Bijector", "BatchNormalization", "Chain", "CholeskyOuterProduct", - "ConditionalBijector", "Exp", "FillTriangular", "Gumbel", "Identity", - "Inline", "Invert", "Kumaraswamy", "MaskedAutoregressiveFlow", - "MatrixInverseTriL", "Permute", "PowerTransform", "RealNVP", "Reshape", - "ScaleTriL", "Sigmoid", "SinhArcsinh", "SoftmaxCentered", "Softplus", - "Softsign", "Square", "TransformDiagonal", "Weibull", - "masked_autoregressive_default_template", "masked_dense", - "real_nvp_default_template" -] - -remove_undocumented(__name__, __all__) diff --git a/tensorflow_probability/python/distributions/conditional_transformed_distribution_test.py b/tensorflow_probability/python/distributions/conditional_transformed_distribution_test.py index f7cd586ab4..d9402cbbf9 100644 --- a/tensorflow_probability/python/distributions/conditional_transformed_distribution_test.py +++ b/tensorflow_probability/python/distributions/conditional_transformed_distribution_test.py @@ -23,8 +23,8 @@ import tensorflow as tf import tensorflow_probability as tfp +from tensorflow_probability.python.bijectors.conditional_bijector import ConditionalBijector from tensorflow_probability.python.distributions import transformed_distribution_test -from tensorflow_probability.python.distributions.bijectors.conditional_bijector import ConditionalBijector tfd = tfp.distributions diff --git a/tensorflow_probability/python/distributions/kumaraswamy.py b/tensorflow_probability/python/distributions/kumaraswamy.py index 1d3d5cbd67..7b53dd90ef 100644 --- a/tensorflow_probability/python/distributions/kumaraswamy.py +++ b/tensorflow_probability/python/distributions/kumaraswamy.py @@ -22,7 +22,7 @@ import numpy as np import tensorflow as tf -from tensorflow_probability.python.distributions import bijectors +from tensorflow_probability.python import bijectors from tensorflow_probability.python.internal import distribution_util from tensorflow.python.ops import control_flow_ops from tensorflow.python.ops.distributions import transformed_distribution diff --git a/tensorflow_probability/python/distributions/lognormal.py b/tensorflow_probability/python/distributions/lognormal.py index c656ad9a54..2bf84b5c35 100644 --- a/tensorflow_probability/python/distributions/lognormal.py +++ b/tensorflow_probability/python/distributions/lognormal.py @@ -20,7 +20,7 @@ import numpy as np import tensorflow as tf -from tensorflow_probability.python.distributions.bijectors import Exp +from tensorflow_probability.python.bijectors import Exp from tensorflow.python.ops.distributions import transformed_distribution diff --git a/tensorflow_probability/python/distributions/mvn_diag_test.py b/tensorflow_probability/python/distributions/mvn_diag_test.py index de490a895f..88950273c5 100644 --- a/tensorflow_probability/python/distributions/mvn_diag_test.py +++ b/tensorflow_probability/python/distributions/mvn_diag_test.py @@ -57,7 +57,7 @@ def testDistWithBatchShapeOneThenTransformedThroughSoftplus(self): with self.test_session(): base_dist = tfd.MultivariateNormalDiag(mu, diag, validate_args=True) dist = tfd.TransformedDistribution( - base_dist, validate_args=True, bijector=tfd.bijectors.Softplus()) + base_dist, validate_args=True, bijector=tfp.bijectors.Softplus()) samps = dist.sample(5) # Shape [5, 1, 3]. self.assertAllEqual([5, 1], dist.log_prob(samps).get_shape()) diff --git a/tensorflow_probability/python/distributions/mvn_linear_operator.py b/tensorflow_probability/python/distributions/mvn_linear_operator.py index eba16e6961..028e9f9b0b 100644 --- a/tensorflow_probability/python/distributions/mvn_linear_operator.py +++ b/tensorflow_probability/python/distributions/mvn_linear_operator.py @@ -19,7 +19,7 @@ from __future__ import print_function import tensorflow as tf -from tensorflow_probability.python.distributions.bijectors import AffineLinearOperator +from tensorflow_probability.python.bijectors import AffineLinearOperator from tensorflow_probability.python.internal import distribution_util from tensorflow.python.ops.distributions import transformed_distribution diff --git a/tensorflow_probability/python/distributions/poisson_lognormal.py b/tensorflow_probability/python/distributions/poisson_lognormal.py index 392a45e95f..315a906e83 100644 --- a/tensorflow_probability/python/distributions/poisson_lognormal.py +++ b/tensorflow_probability/python/distributions/poisson_lognormal.py @@ -22,7 +22,7 @@ import numpy as np import tensorflow as tf -from tensorflow_probability.python.distributions.bijectors.exp import Exp +from tensorflow_probability.python.bijectors.exp import Exp from tensorflow_probability.python.distributions.poisson import Poisson from tensorflow_probability.python.internal import distribution_util from tensorflow.python.framework import tensor_shape diff --git a/tensorflow_probability/python/distributions/relaxed_bernoulli.py b/tensorflow_probability/python/distributions/relaxed_bernoulli.py index b727387609..63ff0bd845 100644 --- a/tensorflow_probability/python/distributions/relaxed_bernoulli.py +++ b/tensorflow_probability/python/distributions/relaxed_bernoulli.py @@ -19,7 +19,7 @@ from __future__ import print_function import tensorflow as tf -from tensorflow_probability.python.distributions.bijectors.sigmoid import Sigmoid +from tensorflow_probability.python.bijectors.sigmoid import Sigmoid # Bijectors must be directly imported because `remove_undocumented` prevents # individual file imports. from tensorflow_probability.python.distributions.logistic import Logistic diff --git a/tensorflow_probability/python/distributions/relaxed_onehot_categorical.py b/tensorflow_probability/python/distributions/relaxed_onehot_categorical.py index db149518d3..6550c212ea 100644 --- a/tensorflow_probability/python/distributions/relaxed_onehot_categorical.py +++ b/tensorflow_probability/python/distributions/relaxed_onehot_categorical.py @@ -21,7 +21,7 @@ # Dependency imports import numpy as np import tensorflow as tf -from tensorflow_probability.python.distributions import bijectors +from tensorflow_probability.python import bijectors from tensorflow.python.ops import control_flow_ops from tensorflow.python.ops.distributions import transformed_distribution from tensorflow.python.ops.distributions import util as distribution_util diff --git a/tensorflow_probability/python/distributions/sinh_arcsinh.py b/tensorflow_probability/python/distributions/sinh_arcsinh.py index 86405f6aa5..5d1bf13ad6 100644 --- a/tensorflow_probability/python/distributions/sinh_arcsinh.py +++ b/tensorflow_probability/python/distributions/sinh_arcsinh.py @@ -19,7 +19,7 @@ from __future__ import print_function import tensorflow as tf -from tensorflow_probability.python.distributions import bijectors +from tensorflow_probability.python import bijectors from tensorflow_probability.python.internal import distribution_util from tensorflow.python.ops import control_flow_ops from tensorflow.python.ops.distributions import transformed_distribution diff --git a/tensorflow_probability/python/distributions/transformed_distribution_test.py b/tensorflow_probability/python/distributions/transformed_distribution_test.py index 837f2075aa..83109f70e8 100644 --- a/tensorflow_probability/python/distributions/transformed_distribution_test.py +++ b/tensorflow_probability/python/distributions/transformed_distribution_test.py @@ -24,10 +24,8 @@ import tensorflow as tf import tensorflow_probability as tfp - tfd = tfp.distributions - -tfb = tfp.distributions.bijectors +tfb = tfp.bijectors class DummyMatrixTransform(tfb.Bijector): @@ -269,7 +267,7 @@ def testScalarBatchScalarEventIdentityScale(self): with self.test_session() as sess: exp2 = self._cls()( tfd.Exponential(rate=0.25), - bijector=tfd.bijectors.AffineScalar(scale=2.)) + bijector=tfb.AffineScalar(scale=2.)) log_prob = exp2.log_prob(1.) log_prob_ = sess.run(log_prob) base_log_prob = -0.5 * 0.25 + np.log(0.25) diff --git a/tensorflow_probability/python/distributions/vector_diffeomixture.py b/tensorflow_probability/python/distributions/vector_diffeomixture.py index 60ed9a5577..77e89b6366 100644 --- a/tensorflow_probability/python/distributions/vector_diffeomixture.py +++ b/tensorflow_probability/python/distributions/vector_diffeomixture.py @@ -22,8 +22,8 @@ import numpy as np import tensorflow as tf -from tensorflow_probability.python.distributions.bijectors.affine_linear_operator import AffineLinearOperator -from tensorflow_probability.python.distributions.bijectors.softmax_centered import SoftmaxCentered +from tensorflow_probability.python.bijectors.affine_linear_operator import AffineLinearOperator +from tensorflow_probability.python.bijectors.softmax_centered import SoftmaxCentered from tensorflow_probability.python.internal import distribution_util from tensorflow.contrib.linalg.python.ops import linear_operator_addition as linop_add_lib from tensorflow.python.framework import tensor_util diff --git a/tensorflow_probability/python/distributions/vector_exponential_linear_operator.py b/tensorflow_probability/python/distributions/vector_exponential_linear_operator.py index a275616d52..aaa513216c 100644 --- a/tensorflow_probability/python/distributions/vector_exponential_linear_operator.py +++ b/tensorflow_probability/python/distributions/vector_exponential_linear_operator.py @@ -19,7 +19,7 @@ from __future__ import print_function import tensorflow as tf -from tensorflow_probability.python.distributions import bijectors +from tensorflow_probability.python import bijectors from tensorflow_probability.python.internal import distribution_util from tensorflow.python.ops.distributions import exponential from tensorflow.python.ops.distributions import transformed_distribution diff --git a/tensorflow_probability/python/distributions/vector_laplace_diag_test.py b/tensorflow_probability/python/distributions/vector_laplace_diag_test.py index 0be504d8a3..a2bf01f3d0 100644 --- a/tensorflow_probability/python/distributions/vector_laplace_diag_test.py +++ b/tensorflow_probability/python/distributions/vector_laplace_diag_test.py @@ -56,7 +56,7 @@ def testDistWithBatchShapeOneThenTransformedThroughSoftplus(self): with self.test_session(): base_dist = tfd.VectorLaplaceDiag(mu, diag, validate_args=True) dist = tfd.TransformedDistribution( - base_dist, validate_args=True, bijector=tfd.bijectors.Softplus()) + base_dist, validate_args=True, bijector=tfp.bijectors.Softplus()) samps = dist.sample(5) # Shape [5, 1, 3]. self.assertAllEqual([5, 1], dist.log_prob(samps).get_shape()) diff --git a/tensorflow_probability/python/distributions/vector_laplace_linear_operator.py b/tensorflow_probability/python/distributions/vector_laplace_linear_operator.py index 32104a7473..ed5a43e51a 100644 --- a/tensorflow_probability/python/distributions/vector_laplace_linear_operator.py +++ b/tensorflow_probability/python/distributions/vector_laplace_linear_operator.py @@ -22,7 +22,7 @@ import numpy as np import tensorflow as tf -from tensorflow_probability.python.distributions import bijectors +from tensorflow_probability.python import bijectors from tensorflow_probability.python.internal import distribution_util from tensorflow.python.ops.distributions import laplace from tensorflow.python.ops.distributions import transformed_distribution diff --git a/tensorflow_probability/python/distributions/vector_sinh_arcsinh_diag.py b/tensorflow_probability/python/distributions/vector_sinh_arcsinh_diag.py index d80a3ab766..9493ca62d3 100644 --- a/tensorflow_probability/python/distributions/vector_sinh_arcsinh_diag.py +++ b/tensorflow_probability/python/distributions/vector_sinh_arcsinh_diag.py @@ -19,7 +19,7 @@ from __future__ import print_function import tensorflow as tf -from tensorflow_probability.python.distributions import bijectors +from tensorflow_probability.python import bijectors from tensorflow_probability.python.internal import distribution_util from tensorflow.python.ops import control_flow_ops from tensorflow.python.ops.distributions import transformed_distribution diff --git a/tensorflow_probability/python/distributions/vector_student_t.py b/tensorflow_probability/python/distributions/vector_student_t.py index 3da6c9bb36..46c49fe1b9 100644 --- a/tensorflow_probability/python/distributions/vector_student_t.py +++ b/tensorflow_probability/python/distributions/vector_student_t.py @@ -19,7 +19,7 @@ from __future__ import print_function import tensorflow as tf -from tensorflow_probability.python.distributions import bijectors +from tensorflow_probability.python import bijectors from tensorflow_probability.python.internal import distribution_util from tensorflow.python.ops.distributions import student_t from tensorflow.python.ops.distributions import transformed_distribution @@ -114,7 +114,7 @@ class _VectorStudentT(transformed_distribution.TransformedDistribution): ``` For more examples of how to construct the `scale` matrix, see the - `tf.contrib.distributions.bijectors.Affine` docstring. + `tf.contrib.bijectors.Affine` docstring. """ diff --git a/tensorflow_probability/python/mcmc/transformed_kernel_test.py b/tensorflow_probability/python/mcmc/transformed_kernel_test.py index 2e3631794e..64ff2ee70d 100644 --- a/tensorflow_probability/python/mcmc/transformed_kernel_test.py +++ b/tensorflow_probability/python/mcmc/transformed_kernel_test.py @@ -27,7 +27,7 @@ tfd = tfp.distributions -tfb = tfd.bijectors +tfb = tfp.bijectors FakeInnerKernelResults = collections.namedtuple(