tfmri.convex.ConvexFunction

class ConvexFunction(domain_dimension=None, scale=None, dtype=None, name=None)[source]

Bases: object

Base class defining a [batch of] convex function[s].

Represents a closed proper convex function \(f : \mathbb{R}^{n}\rightarrow \mathbb{R}\) or \(f : \mathbb{C}^{n}\rightarrow \mathbb{R}\).

Subclasses should implement the _call and _prox methods to define the forward pass and the proximal mapping, respectively. Gradients are provided by TensorFlow’s automatic differentiation feature.

This class exposes three properties to get static shape information:

  • shape: The static shape. Calls _shape.

  • domain_dimension: The static domain dimension, equal to shape[-1].

  • batch_shape: The static batch shape, equal to shape[:-1].

Additionally there are three equivalent methods to get dynamic shape information:

  • shape_tensor: The dynamic shape. Calls _shape_tensor.

  • domain_dimension_tensor: The dynamic domain dimension, equal to shape_tensor()[-1].

  • batch_shape_tensor: The dynamic batch shape, equal to shape_tensor()[:-1].

Subclasses may implement the methods _shape and _shape_tensor to provide custom static and dynamic shape information, respectively.

Initialize this ConvexFunction.

property batch_shape

The static batch shape of this ConvexFunction.

batch_shape_tensor(name=None)[source]

Returns the dynamic batch shape of this ConvexFunction.

Subclasses get this for free once they implement _shape_tensor.

Parameters

name – A name for this operation (optional).

Returns

A 1D integer tf.Tensor.

call(x, name=None)[source]

Evaluate this ConvexFunction at input point[s] x.

Parameters
  • x

    A tf.Tensor of shape [..., n] and same dtype as self.

  • name – A name for this operation (optional).

Returns

A tf.Tensor of shape [...] and same dtype as self.

conj(name=None)[source]

Returns the convex conjugate of this ConvexFunction.

Parameters

name – A name for this operation (optional).

Returns

A ConvexFunction which represents the convex conjugate of self.

property domain_dimension

The static domain dimension of this ConvexFunction.

domain_dimension_tensor(name=None)[source]

Returns the dynamic domain dimension of this ConvexFunction.

Subclasses get this for free once they implement _shape_tensor.

Parameters

name – A name for this operation (optional).

Returns

A scalar integer tf.Tensor.

property dtype

The DType of Tensors handled by this ConvexFunction.

property name

Name prepended to all ops created by this ConvexFunction.

ndim_tensor(name=None)

Returns the dynamic domain dimension of this ConvexFunction. (deprecated)

Deprecated: THIS FUNCTION IS DEPRECATED. It will be removed after 2022-08-07. Instructions for updating: Use ConvexFunction.domain_dimension_tensor instead.

Parameters

name – A name for this operation (optional).

Returns

A scalar integer tf.Tensor.

prox(x, scale=None, name=None, **kwargs)[source]

Evaluate the proximal operator of this ConvexFunction at point[s] x.

Parameters
  • x

    A tf.Tensor of shape [..., n] and same dtype as self.

  • scale – A scalar float. Additional scaling factor.

  • name – A name for this operation (optional).

  • **kwargs – A dict. Additional keyword arguments to pass to _prox.

Returns

A tf.Tensor of shape [..., n] and same dtype as self.

property scale

The scaling factor.

property shape

The static shape of this ConvexFunction.

shape_tensor(name=None)[source]

Returns the dynamic shape of this ConvexFunction.

Parameters

name – A name for this operation (optional).

Returns

A 1D integer tf.Tensor.