garage.tf.distributions package

class Distribution[source]

Bases: object

Base class for distribution.

dim

Dimension of this distribution.

Type:int
dist_info_keys

Parameter names.

Type:list
dist_info_specs

Specification of the parameter of a distribution.

Type:list
entropy(dist_info)[source]

Entropy of a distribution.

Parameters:dist_info (dict) – Parameters of a distribution.
Returns:Entropy of the distribution.
Return type:float
entropy_sym(dist_info_vars, name='entropy_sym')[source]

Symbolic entropy of a distribution.

Parameters:
  • dist_info_vars (dict) – Symbolic parameters of a distribution.
  • name (str) – TensorFlow scope name.
Returns:

Symbolic entropy of the distribution.

Return type:

tf.Tensor

kl(old_dist_info, new_dist_info)[source]

Compute the KL divergence of two distributions.

Parameters:
  • old_dist_info (dict) – Parameters of the old distribution.
  • new_dist_info (dict) – Parameters of the new distribution.
Returns:

KL Divergence between two distributions.

Return type:

float

kl_sym(old_dist_info_vars, new_dist_info_vars, name='kl_sym')[source]

Compute the symbolic KL divergence of two distributions.

Parameters:
  • old_dist_info_vars (tf.Tensor) – Symbolic parameters of the old distribution.
  • new_dist_info_vars (tf.Tensor) – Symbolic parameters of the new distribution.
  • name (str) – TensorFlow scope name.
Returns:

Symbolic KL divergence between the two distributions.

Return type:

tf.Tensor

likelihood_ratio_sym(x_var, old_dist_info_vars, new_dist_info_vars, name='ll_ratio_sym')[source]

Symbolic likelihood ratio.

Parameters:
  • x_var (tf.Tensor) – Input placeholder.
  • old_dist_info_vars (dict) – Old distribution tensors.
  • new_dist_info_vars (dict) – New distribution tensors.
  • name (str) – TensorFlow scope name.
Returns:

Symbolic likelihood ratio.

Return type:

tf.Tensor

log_likelihood(xs, dist_info)[source]

Log likelihood of a sample under a distribution.

Parameters:
  • xs (np.ndarray) – Input value.
  • dist_info (dict) – Parameters of a distribution.
Returns:

Log likelihood of a sample under the distribution.

Return type:

float

log_likelihood_sym(x_var, dist_info_vars, name='ll_sym')[source]

Symbolic log likelihood.

Parameters:
  • x_var (tf.Tensor) – Input placeholder.
  • dist_info_vars (dict) – Parameters of a distribution.
  • name (str) – TensorFlow scope name.
Returns:

Symbolic log likelihood.

Return type:

tf.Tensor

class Bernoulli(dim, name='Bernoulli')[source]

Bases: garage.tf.distributions.distribution.Distribution

dim

Dimension of this distribution.

Type:int
dist_info_keys

Parameter names.

Type:list
entropy(dist_info)[source]

Entropy of a distribution.

Parameters:dist_info (dict) – Parameters of a distribution.
Returns:Entropy of the distribution.
Return type:float
kl(old_dist_info, new_dist_info)[source]

Compute the KL divergence of two distributions.

Parameters:
  • old_dist_info (dict) – Parameters of the old distribution.
  • new_dist_info (dict) – Parameters of the new distribution.
Returns:

KL Divergence between two distributions.

Return type:

float

kl_sym(old_dist_info_vars, new_dist_info_vars, name='kl_sym')[source]

Compute the symbolic KL divergence of two distributions.

Parameters:
  • old_dist_info_vars (tf.Tensor) – Symbolic parameters of the old distribution.
  • new_dist_info_vars (tf.Tensor) – Symbolic parameters of the new distribution.
  • name (str) – TensorFlow scope name.
Returns:

Symbolic KL divergence between the two distributions.

Return type:

tf.Tensor

likelihood_ratio_sym(x_var, old_dist_info_vars, new_dist_info_vars, name='likelihood_ratio_sym')[source]

Symbolic likelihood ratio.

Parameters:
  • x_var (tf.Tensor) – Input placeholder.
  • old_dist_info_vars (dict) – Old distribution tensors.
  • new_dist_info_vars (dict) – New distribution tensors.
  • name (str) – TensorFlow scope name.
Returns:

Symbolic likelihood ratio.

Return type:

tf.Tensor

log_likelihood(xs, dist_info)[source]

Log likelihood of a sample under a distribution.

Parameters:
  • xs (np.ndarray) – Input value.
  • dist_info (dict) – Parameters of a distribution.
Returns:

Log likelihood of a sample under the distribution.

Return type:

float

log_likelihood_sym(x_var, dist_info_vars, name='log_likelihood_sym')[source]

Symbolic log likelihood.

Parameters:
  • x_var (tf.Tensor) – Input placeholder.
  • dist_info_vars (dict) – Parameters of a distribution.
  • name (str) – TensorFlow scope name.
Returns:

Symbolic log likelihood.

Return type:

tf.Tensor

sample(dist_info)[source]
class Categorical(dim, name=None)[source]

Bases: garage.tf.distributions.distribution.Distribution

cross_entropy_sym(old_dist_info_vars, new_dist_info_vars, name='cross_entropy_sym')[source]
dim

Dimension of this distribution.

Type:int
dist_info_specs

Specification of the parameter of a distribution.

Type:list
entropy(info)[source]

Entropy of a distribution.

Parameters:dist_info (dict) – Parameters of a distribution.
Returns:Entropy of the distribution.
Return type:float
entropy_sym(dist_info_vars)[source]

Symbolic entropy of a distribution.

Parameters:
  • dist_info_vars (dict) – Symbolic parameters of a distribution.
  • name (str) – TensorFlow scope name.
Returns:

Symbolic entropy of the distribution.

Return type:

tf.Tensor

kl(old_dist_info, new_dist_info)[source]

Compute the KL divergence of two categorical distributions

kl_sym(old_dist_info_vars, new_dist_info_vars, name='kl_sym')[source]

Compute the symbolic KL divergence of two categorical distributions

likelihood_ratio_sym(x_var, old_dist_info_vars, new_dist_info_vars, name='likelihood_ratio_sym')[source]

Symbolic likelihood ratio.

Parameters:
  • x_var (tf.Tensor) – Input placeholder.
  • old_dist_info_vars (dict) – Old distribution tensors.
  • new_dist_info_vars (dict) – New distribution tensors.
  • name (str) – TensorFlow scope name.
Returns:

Symbolic likelihood ratio.

Return type:

tf.Tensor

log_likelihood(xs, dist_info)[source]

Log likelihood of a sample under a distribution.

Parameters:
  • xs (np.ndarray) – Input value.
  • dist_info (dict) – Parameters of a distribution.
Returns:

Log likelihood of a sample under the distribution.

Return type:

float

log_likelihood_sym(x_var, dist_info_vars, name='log_likelihood_sym')[source]

Symbolic log likelihood.

Parameters:
  • x_var (tf.Tensor) – Input placeholder.
  • dist_info_vars (dict) – Parameters of a distribution.
  • name (str) – TensorFlow scope name.
Returns:

Symbolic log likelihood.

Return type:

tf.Tensor

sample(dist_info)[source]
sample_sym(dist_info, name='sample_sym')[source]
class DiagonalGaussian(dim, name='DiagonalGaussian')[source]

Bases: garage.tf.distributions.distribution.Distribution

Diagonal Gaussian Distribution.

Parameters:
  • dim (int) – Dimension of the distribution.
  • name (str) – Name (scope) of the distribution.
dim

Dimension of the distribution.

Type:int
dist_info_specs

Specification of the parameter of a distribution.

Type:list
entropy(dist_info)[source]

Entropy of a distribution.

Parameters:dist_info (dict) – Parameters of a distribution.
Returns:Entropy of the distribution.
Return type:float
entropy_sym(dist_info_vars, name='entropy_sym')[source]

Symbolic entropy of a distribution.

Parameters:
  • dist_info_vars (dict) – Symbolic parameters of a distribution.
  • name (str) – TensorFlow scope name.
Returns:

Symbolic entropy of the distribution.

Return type:

tf.Tensor

kl(old_dist_info, new_dist_info)[source]

KL Divergence between the old and the new distribution.

Parameters:
  • old_dist_info (dict) – Parameters of the old distribution.
  • new_dist_info (dict) – Parameters of the new distribution.
Returns:

KL Divergence between two distributions.

Return type:

float

kl_sym(old_dist_info_vars, new_dist_info_vars, name='kl_sym')[source]

Symbolic KL between the old and the new distribution.

Parameters:
  • old_dist_info_vars (tf.Tensor) – Symbolic parameters of the old distribution.
  • new_dist_info_vars (tf.Tensor) – Symbolic parameters of the new distribution.
  • name (str) – TensorFlow scope name.
Returns:

Symbolic KL divergence between the two distributions.

Return type:

tf.Tensor

likelihood_ratio_sym(x_var, old_dist_info_vars, new_dist_info_vars, name='likelihood_ratio_sym')[source]

Symbolic likelihood ratio.

Parameters:
  • x_var (tf.Tensor) – Input placeholder.
  • old_dist_info_vars (dict) – Old distribution tensors.
  • new_dist_info_vars (dict) – New distribution tensors.
  • name (str) – TensorFlow scope name.
Returns:

Symbolic likelihood ratio.

Return type:

tf.Tensor

log_likelihood(xs, dist_info)[source]

Log likelihood of a sample under a distribution.

Parameters:
  • xs (np.ndarray) – Input value.
  • dist_info (dict) – Parameters of a distribution.
Returns:

Log likelihood of a sample under the distribution.

Return type:

float

log_likelihood_sym(x_var, dist_info_vars, name='log_likelihood_sym')[source]

Symbolic log likelihood.

Parameters:
  • x_var (tf.Tensor) – Input placeholder.
  • dist_info_vars (dict) – Parameters of a distribution.
  • name (str) – TensorFlow scope name.
Returns:

Symbolic log likelihood.

Return type:

tf.Tensor

sample(dist_info)[source]

Sample a value given a distribution.

Parameters:dist_info (dict) – Parameters of a distribution.
Returns:A sample from the distribution.
Return type:np.ndarray
sample_sym(dist_info_vars)[source]

Sample a symbolic value given a distribution.

Parameters:dist_info_vars (dict) – Symbolic parameters of a distribution.
Returns:A symbolic sample from the distribution.
Return type:tf.Tensor
class RecurrentCategorical(dim, name='RecurrentCategorical')[source]

Bases: garage.tf.distributions.distribution.Distribution

dim

Dimension of this distribution.

Type:int
dist_info_specs

Specification of the parameter of a distribution.

Type:list
entropy(dist_info)[source]

Entropy of a distribution.

Parameters:dist_info (dict) – Parameters of a distribution.
Returns:Entropy of the distribution.
Return type:float
entropy_sym(dist_info_vars, name='entropy_sym')[source]

Symbolic entropy of a distribution.

Parameters:
  • dist_info_vars (dict) – Symbolic parameters of a distribution.
  • name (str) – TensorFlow scope name.
Returns:

Symbolic entropy of the distribution.

Return type:

tf.Tensor

kl(old_dist_info, new_dist_info)[source]

Compute the KL divergence of two categorical distributions

kl_sym(old_dist_info_vars, new_dist_info_vars, name='kl_sym')[source]

Compute the symbolic KL divergence of two categorical distributions

likelihood_ratio_sym(x_var, old_dist_info_vars, new_dist_info_vars, name='likelihood_ratio_sym')[source]

Symbolic likelihood ratio.

Parameters:
  • x_var (tf.Tensor) – Input placeholder.
  • old_dist_info_vars (dict) – Old distribution tensors.
  • new_dist_info_vars (dict) – New distribution tensors.
  • name (str) – TensorFlow scope name.
Returns:

Symbolic likelihood ratio.

Return type:

tf.Tensor

log_likelihood(xs, dist_info)[source]

Log likelihood of a sample under a distribution.

Parameters:
  • xs (np.ndarray) – Input value.
  • dist_info (dict) – Parameters of a distribution.
Returns:

Log likelihood of a sample under the distribution.

Return type:

float

log_likelihood_sym(xs, dist_info_vars, name='log_likelihood_sym')[source]

Symbolic log likelihood.

Parameters:
  • x_var (tf.Tensor) – Input placeholder.
  • dist_info_vars (dict) – Parameters of a distribution.
  • name (str) – TensorFlow scope name.
Returns:

Symbolic log likelihood.

Return type:

tf.Tensor

RecurrentDiagonalGaussian

alias of garage.tf.distributions.diagonal_gaussian.DiagonalGaussian