TransportMaps.Maps.MapBase

Module Contents

Classes

Map

Abstract map \(T:\mathbb{R}^{d_x}\rightarrow\mathbb{R}^{d_y}\)

class TransportMaps.Maps.MapBase.Map(**kwargs)[source]

Bases: TransportMaps.ObjectBase.TMO

Abstract map \(T:\mathbb{R}^{d_x}\rightarrow\mathbb{R}^{d_y}\)

Parameters:
  • dim_in (int) – input dimension

  • dim_out (int) – output dimension

property dim_in[source]
property dim_out[source]
property dim[source]
__call__(x)[source]

Calls evaluate().

get_ncalls_tree(indent='')[source]
get_nevals_tree(indent='')[source]
get_teval_tree(indent='')[source]
update_ncalls_tree(obj)[source]
update_nevals_tree(obj)[source]
update_teval_tree(obj)[source]
reset_counters()[source]
abstract evaluate(x, precomp=None, idxs_slice=slice(None), **kwargs)[source]

[Abstract] Evaluate the map \(T\) at the points \({\bf x} \in \mathbb{R}^{m \times d_x}\).

Parameters:
  • x (ndarray [\(m,d_x\)]) – evaluation points

  • precomp (dict) – dictionary of precomputed values

  • idxs_slice (slice) – if precomputed values are present, this parameter indicates at which of the points to evaluate. The number of indices represented by idxs_slice must match x.shape[0].

Returns:

(ndarray [\(m,d_y\)]) – transformed points

Raises:

NotImplementedError – to be implemented in sub-classes

abstract grad_x(x, precomp=None, idxs_slice=slice(None), **kwargs)[source]

[Abstract] Evaluate the gradient \(\nabla_{\bf x}T\) at the points \({\bf x} \in \mathbb{R}^{m \times d_x}\).

Parameters:
  • x (ndarray [\(m,d_x\)]) – evaluation points

  • precomp (dict) – dictionary of precomputed values

  • idxs_slice (slice) – if precomputed values are present, this parameter indicates at which of the points to evaluate. The number of indices represented by idxs_slice must match x.shape[0].

Returns:

(ndarray [\(m,d_y,d_x\)]) – transformed points

Raises:

NotImplementedError – to be implemented in sub-classes

abstract action_grad_x(x, dx, precomp=None, idxs_slice=slice(None), **kwargs)[source]

[Abstract] Evaluate the action of the gradient \(\langle\nabla_{\bf x}T({\bf x}),\delta{\bf x}\rangle\) at the points \({\bf x} \in \mathbb{R}^{m \times d_x}\) on the vector \(\delta{\bf x}\).

Parameters:
  • x (ndarray [\(m,d_x\)]) – evaluation points

  • dx (ndarray [\(m,d_x,...\)]) – vector \(\delta{\bf x}\)

  • precomp (dict) – dictionary of precomputed values

  • idxs_slice (slice) – if precomputed values are present, this parameter indicates at which of the points to evaluate. The number of indices represented by idxs_slice must match x.shape[0].

Returns:

(ndarray [\(m,d_y,...\)]) – transformed points

Raises:

NotImplementedError – to be implemented in sub-classes

abstract action_adjoint_grad_x(x, dx, precomp=None, idxs_slice=slice(None), **kwargs)[source]

[Abstract] Evaluate the action of the gradient \(\langle\delta{\bf x},\nabla_{\bf x}T({\bf x})\rangle\) at the points \({\bf x} \in \mathbb{R}^{m \times d_x}\) on the vector \(\delta{\bf x}\).

Parameters:
  • x (ndarray [\(m,d_x\)]) – evaluation points

  • dx (ndarray [\(m,d_x,...\)]) – vector \(\delta{\bf x}\)

  • precomp (dict) – dictionary of precomputed values

  • idxs_slice (slice) – if precomputed values are present, this parameter indicates at which of the points to evaluate. The number of indices represented by idxs_slice must match x.shape[0].

Returns:

(ndarray [\(m,d_y,...\)]) – transformed points

Raises:

NotImplementedError – to be implemented in sub-classes

abstract tuple_grad_x(x, precomp=None, idxs_slice=slice(None), **kwargs)[source]

[Abstract] Evaluate the function and gradient.

Parameters:
  • x (ndarray [\(m,d_x\)]) – evaluation points

  • precomp (dict) – dictionary of precomputed values

  • idxs_slice (slice) – if precomputed values are present, this parameter indicates at which of the points to evaluate. The number of indices represented by idxs_slice must match x.shape[0].

Returns:

(tuple) – function and gradient evaluation

Raises:

NotImplementedError – to be implemented in sub-classes

abstract action_tuple_grad_x(x, dx, precomp=None, idxs_slice=slice(None), **kwargs)[source]

[Abstract] Evaluate the function and action of the gradient.

Parameters:
  • x (ndarray [\(m,d_x\)]) – evaluation points

  • dx (ndarray [\(m,d_x,...\)]) – vector \(\delta{\bf x}\)

  • precomp (dict) – dictionary of precomputed values

  • idxs_slice (slice) – if precomputed values are present, this parameter indicates at which of the points to evaluate. The number of indices represented by idxs_slice must match x.shape[0].

Returns:

(tuple) – function and action of the gradient evaluation

Raises:

NotImplementedError – to be implemented in sub-classes

abstract hess_x(x, precomp=None, idxs_slice=slice(None), **kwargs)[source]

[Abstract] Evaluate the Hessian \(\nabla^2_{\bf x}T\) at the points \({\bf x} \in \mathbb{R}^{m \times d_x}\).

Parameters:
  • x (ndarray [\(m,d_x\)]) – evaluation points

  • precomp (dict) – dictionary of precomputed values

  • idxs_slice (slice) – if precomputed values are present, this parameter indicates at which of the points to evaluate. The number of indices represented by idxs_slice must match x.shape[0].

Returns:

(ndarray [\(m,d_y,d_x,d_x\)]) – transformed points

Raises:

NotImplementedError – to be implemented in sub-classes

abstract action_hess_x(x, dx, precomp=None, idxs_slice=slice(None), **kwargs)[source]

[Abstract] Evaluate the action of the Hessian \(\langle\nabla^2_{\bf x}T,\delta{\bf x}\rangle\) at the points \({\bf x} \in \mathbb{R}^{m \times d_x}\).

Parameters:
  • x (ndarray [\(m,d_x\)]) – evaluation points

  • dx (ndarray [\(m,d_x\)]) – direction on which to evaluate the Hessian

  • precomp (dict) – dictionary of precomputed values

  • idxs_slice (slice) – if precomputed values are present, this parameter indicates at which of the points to evaluate. The number of indices represented by idxs_slice must match x.shape[0].

Returns:

(ndarray [\(m,d_y,d_x\)]) – transformed points

Raises:

NotImplementedError – to be implemented in sub-classes

abstract inverse(x, precomp=None, idxs_slice=slice(None), **kwargs)[source]

[Abstract] Evaluate the Moore-Penrose inverse map \(T^\dagger\) at the points \({\bf x} \in \mathbb{R}^{m \times d_x}\).

Parameters:
  • x (ndarray [\(m,d_x\)]) – evaluation points

  • precomp (dict) – dictionary of precomputed values

  • idxs_slice (slice) – if precomputed values are present, this parameter indicates at which of the points to evaluate. The number of indices represented by idxs_slice must match x.shape[0].

Returns:

(ndarray [\(m,d_y\)]) – transformed points

Raises:

NotImplementedError – to be implemented in sub-classes

abstract grad_x_inverse(x, precomp=None, idxs_slice=slice(None), **kwargs)[source]

[Abstract] Evaluate the gradient of the Moore-Penrose inverse \(\nabla_{\bf x}T^\dagger\) at the points \({\bf x} \in \mathbb{R}^{m \times d_x}\).

Parameters:
  • x (ndarray [\(m,d_x\)]) – evaluation points

  • precomp (dict) – dictionary of precomputed values

  • idxs_slice (slice) – if precomputed values are present, this parameter indicates at which of the points to evaluate. The number of indices represented by idxs_slice must match x.shape[0].

Returns:

(ndarray [\(m,d_y,d_x\)]) – transformed points

Raises:

NotImplementedError – to be implemented in sub-classes

abstract tuple_grad_x_inverse(x, precomp=None, idxs_slice=slice(None), **kwargs)[source]

[Abstract] Evaluate the Moore-Penrose inverse function and gradient.

Parameters:
  • x (ndarray [\(m,d_x\)]) – evaluation points

  • precomp (dict) – dictionary of precomputed values

  • idxs_slice (slice) – if precomputed values are present, this parameter indicates at which of the points to evaluate. The number of indices represented by idxs_slice must match x.shape[0].

Returns:

(tuple) – function and gradient evaluation

Raises:

NotImplementedError – to be implemented in sub-classes

abstract hess_x_inverse(x, precomp=None, idxs_slice=slice(None), **kwargs)[source]

[Abstract] Evaluate the Hessian of the Moore-Penrose inverse \(\nabla^2_{\bf x}T^\dagger\) at the points \({\bf x} \in \mathbb{R}^{m \times d_x}\).

Parameters:
  • x (ndarray [\(m,d_x\)]) – evaluation points

  • precomp (dict) – dictionary of precomputed values

  • idxs_slice (slice) – if precomputed values are present, this parameter indicates at which of the points to evaluate. The number of indices represented by idxs_slice must match x.shape[0].

Returns:

(ndarray [\(m,d_y,d_x,d_x\)]) – transformed points

Raises:

NotImplementedError – to be implemented in sub-classes

abstract action_hess_x_inverse(x, dx, precomp=None, idxs_slice=slice(None), **kwargs)[source]

[Abstract] Evaluate the action of the Hessian of the Moore-Penrose inverse \(\langle\nabla^2_{\bf x}T^\dagger,\delta{\bf x}\rangle\) at the points \({\bf x} \in \mathbb{R}^{m \times d_x}\).

Parameters:
  • x (ndarray [\(m,d_x\)]) – evaluation points

  • dx (ndarray [\(m,d_x\)]) – direction on which to evaluate the Hessian

  • precomp (dict) – dictionary of precomputed values

  • idxs_slice (slice) – if precomputed values are present, this parameter indicates at which of the points to evaluate. The number of indices represented by idxs_slice must match x.shape[0].

Returns:

(ndarray [\(m,d_y,d_x\)]) – transformed points

Raises:

NotImplementedError – to be implemented in sub-classes

test_gradients(x, v=None, method='fd', fd_dx=0.0001, verbose=True)[source]

Automatically tests all the gradients implemented.

Parameters:
  • x (ndarray [\(m,d\)]) – evaluation points

  • v (ndarray [\(d\)]) – direction on which to evaluate the action of the Hessian

  • method (str) – method to use for testing. Default fd is finite difference

  • fd_dx (float) – finite difference perturbation

Returns:

bool – whether all the implemented gradients pass the test.