Home | History | Annotate | Download | only in bijectors
      1 # Copyright 2016 The TensorFlow Authors. All Rights Reserved.
      2 #
      3 # Licensed under the Apache License, Version 2.0 (the "License");
      4 # you may not use this file except in compliance with the License.
      5 # You may obtain a copy of the License at
      6 #
      7 #     http://www.apache.org/licenses/LICENSE-2.0
      8 #
      9 # Unless required by applicable law or agreed to in writing, software
     10 # distributed under the License is distributed on an "AS IS" BASIS,
     11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     12 # See the License for the specific language governing permissions and
     13 # limitations under the License.
     14 # ==============================================================================
     15 """ConditionalBijector base."""
     16 
     17 from __future__ import absolute_import
     18 from __future__ import division
     19 from __future__ import print_function
     20 
     21 from tensorflow.python.ops.distributions import bijector
     22 from tensorflow.python.ops.distributions import util as distribution_util
     23 
     24 
     25 __all__ = ["ConditionalBijector"]
     26 
     27 
     28 class ConditionalBijector(bijector.Bijector):
     29   """Conditional Bijector is a Bijector that allows intrinsic conditioning."""
     30 
     31   @distribution_util.AppendDocstring(kwargs_dict={
     32       "**condition_kwargs":
     33       "Named arguments forwarded to subclass implementation."})
     34   def forward(self, x, name="forward", **condition_kwargs):
     35     return self._call_forward(x, name, **condition_kwargs)
     36 
     37   @distribution_util.AppendDocstring(kwargs_dict={
     38       "**condition_kwargs":
     39       "Named arguments forwarded to subclass implementation."})
     40   def inverse(self, y, name="inverse", **condition_kwargs):
     41     return self._call_inverse(y, name, **condition_kwargs)
     42 
     43   @distribution_util.AppendDocstring(kwargs_dict={
     44       "**condition_kwargs":
     45       "Named arguments forwarded to subclass implementation."})
     46   def inverse_log_det_jacobian(
     47       self, y, name="inverse_log_det_jacobian", **condition_kwargs):
     48     return self._call_inverse_log_det_jacobian(y, name, **condition_kwargs)
     49 
     50   @distribution_util.AppendDocstring(kwargs_dict={
     51       "**condition_kwargs":
     52       "Named arguments forwarded to subclass implementation."})
     53   def forward_log_det_jacobian(
     54       self, x, name="forward_log_det_jacobian", **condition_kwargs):
     55     return self._call_forward_log_det_jacobian(x, name, **condition_kwargs)
     56