zhusuan.utils

class TensorArithmeticMixin

Bases: object

Mixin class for implementing tensor arithmetic operations.

The derived class must support tf.convert_to_tensor, in order to inherit from this mixin class.

log_mean_exp(x, axis=None, keepdims=False)

Tensorflow numerically stable log mean of exps across the axis.

Parameters:
  • x – A Tensor.
  • axis – An int or list or tuple. The dimensions to reduce. If None (the default), reduces all dimensions.
  • keepdims – Bool. If true, retains reduced dimensions with length 1. Default to be False.
Returns:

A Tensor after the computation of log mean exp along given axes of x.

merge_dicts(*dict_args)

Given any number of dicts, shallow copy and merge into a new dict, precedence goes to key value pairs in latter dicts.