Type Reshape
Namespace tensorflow.contrib.distributions.bijectors
Parent Bijector
Interfaces IReshape
Reshapes the `event_shape` of a `Tensor`. The semantics generally follow that of `tf.reshape()`, with
a few differences: * The user must provide both the input and output shape, so that
the transformation can be inverted. If an input shape is not
specified, the default assumes a vector-shaped input, i.e.,
event_shape_in = (-1,).
* The `Reshape` bijector automatically broadcasts over the leftmost
dimensions of its input (`sample_shape` and `batch_shape`); only
the rightmost `event_ndims_in` dimensions are reshaped. The
number of dimensions to reshape is inferred from the provided
`event_shape_in` (`event_ndims_in = len(event_shape_in)`). Example usage:
Show Example
import tensorflow_probability as tfp tfb = tfp.bijectors r = tfb.Reshape(event_shape_out=[1, -1]) r.forward([3., 4.]) # shape [2] # ==> [[3., 4.]] # shape [1, 2] r.forward([[1., 2.], [3., 4.]]) # shape [2, 2] # ==> [[[1., 2.]], # [[3., 4.]]] # shape [2, 1, 2] r.inverse([[3., 4.]]) # shape [1,2] # ==> [3., 4.] # shape [2] r.forward_log_det_jacobian(any_value) # ==> 0. r.inverse_log_det_jacobian(any_value) # ==> 0.