LeakyReLU

class tfsnippet.layers.LeakyReLU(alpha=0.2)

Bases: tfsnippet.layers.activations.base.InvertibleActivation

Leaky ReLU activation function.

y = x if x >= 0 else alpha * x

Methods Summary

__call__(…) <==> x(…)
as_flow(value_ndims[, name, scope]) Convert this activation object into a BaseFlow.
inverse_transform(y[, compute_x, …]) Transform y into x, and compute the log-determinant of f^{-1} at y (i.e., \(\log \det \frac{\partial f^{-1}(y)}{\partial y}\)).
transform(x[, compute_y, compute_log_det, …]) Transform x into y, and compute the log-determinant of f at x (i.e., \(\log \det \frac{\partial f(x)}{\partial x}\)).

Methods Documentation

__call__(...) <==> x(...)
as_flow(value_ndims, name=None, scope=None)

Convert this activation object into a BaseFlow.

Parameters:
  • value_ndims (int) – Number of value dimensions in both x and y. x.ndims - value_ndims == log_det.ndims and y.ndims - value_ndims == log_det.ndims.
  • name (str) – Default name of the variable scope. Will be uniquified. If not specified, generate one according to the class name.
  • scope (str) – The name of the variable scope.
Returns:

The flow.

Return type:

InvertibleActivationFlow

inverse_transform(y, compute_x=True, compute_log_det=True, value_ndims=0, name=None)

Transform y into x, and compute the log-determinant of f^{-1} at y (i.e., \(\log \det \frac{\partial f^{-1}(y)}{\partial y}\)).

Parameters:
  • y (Tensor) – The samples of y.
  • compute_x (bool) – Whether or not to compute \(x = f^{-1}(y)\)? Default True.
  • compute_log_det (bool) – Whether or not to compute the log-determinant? Default True.
  • value_ndims (int) – Number of value dimensions. log_det.ndims == y.ndims - value_ndims.
  • name (str) – If specified, will use this name as the TensorFlow operational name scope.
Returns:

x and the (maybe summed) log-determinant.

The items in the returned tuple might be None if corresponding compute_? argument is set to False.

Return type:

(tf.Tensor, tf.Tensor)

Raises:
transform(x, compute_y=True, compute_log_det=True, value_ndims=0, name=None)

Transform x into y, and compute the log-determinant of f at x (i.e., \(\log \det \frac{\partial f(x)}{\partial x}\)).

Parameters:
  • x (Tensor) – The samples of x.
  • compute_y (bool) – Whether or not to compute \(y = f(x)\)? Default True.
  • compute_log_det (bool) – Whether or not to compute the log-determinant? Default True.
  • value_ndims (int) – Number of value dimensions. log_det.ndims == x.ndims - value_ndims.
  • name (str) – If specified, will use this name as the TensorFlow operational name scope.
Returns:

y and the (maybe summed) log-determinant.

The items in the returned tuple might be None if corresponding compute_? argument is set to False.

Return type:

(tf.Tensor, tf.Tensor)

Raises:

RuntimeError – If both compute_y and compute_log_det are set to False.