tfmri.linalg.LinearOperator
tfmri.linalg.LinearOperator¶
- class LinearOperator(dtype, graph_parents=None, is_non_singular=None, is_self_adjoint=None, is_positive_definite=None, is_square=None, name=None, parameters=None)[source]¶
Bases:
tensorflow_mri.python.util.linalg_imaging.LinalgImagingMixin,tensorflow.python.ops.linalg.linear_operator.LinearOperatorBase class defining a [batch of] linear operator[s].
Provides access to common matrix operations without the need to materialize the matrix.
This operator is similar to tf.linalg.LinearOperator, but has additional methods to simplify operations on images, while maintaining compatibility with the TensorFlow linear algebra framework.
Inputs and outputs to this linear operator or its subclasses may have meaningful non-vectorized N-D shapes. Thus this class defines the additional properties
domain_shapeandrange_shapeand the methodsdomain_shape_tensorandrange_shape_tensor. These enrich the information provided by the built-in propertiesshape,domain_dimension,range_dimensionand methodsdomain_dimension_tensorandrange_dimension_tensor, which only have information about the vectorized 1D shapes.Subclasses of this operator must define the methods
_domain_shapeand_range_shape, which return the static domain and range shapes of the operator. Optionally, subclasses may also define the methods_domain_shape_tensorand_range_shape_tensor, which return the dynamic domain and range shapes of the operator. These two methods will only be called if_domain_shapeand_range_shapedo not return fully defined static shapes.Subclasses must define the abstract method
_transform, which applies the operator (or its adjoint) to a [batch of] images. This internal method is called bytransform. In general, subclasses of this operator should not define the methods_matvecor_matmul. These have default implementations which call_transform.Operators derived from this class may be used in any of the following ways:
Using method
transform, which expects a full-shaped input and returns a full-shaped output, i.e. a tensor with shape[...] + shape, whereshapeis either thedomain_shapeor therange_shape. This method is unique to operators derived from this class.Using method
matvec, which expects a vectorized input and returns a vectorized output, i.e. a tensor with shape[..., n]wherenis either thedomain_dimensionor therange_dimension. This method is part of the TensorFlow linear algebra framework.Using method
matmul, which expects matrix inputs and returns matrix outputs. Note that a matrix is just a column vector in this context, i.e. a tensor with shape[..., n, 1], wherenis either thedomain_dimensionor therange_dimension. Matrices which are not column vectors (i.e. whose last dimension is not 1) are not supported. This method is part of the TensorFlow linear algebra framework.
Operators derived from this class may also be used with the functions tf.linalg.matvec and tf.linalg.matmul, which will call the corresponding methods.
This class also provides the convenience functions
flatten_domain_shapeandflatten_range_shapeto flatten full-shaped inputs/outputs to their vectorized form. Conversely,expand_domain_dimensionandexpand_range_dimensionmay be used to expand vectorized inputs/outputs to their full-shaped form.Subclassing
Subclasses must always define
_transform, which implements this operator’s functionality (and its adjoint). In general, subclasses should not define the methods_matvecor_matmul. These have default implementations which call_transform.Subclasses must always define
_domain_shapeand_range_shape, which return the static domain/range shapes of the operator. If the subclassed operator needs to provide dynamic domain/range shapes and the static shapes are not always fully-defined, it must also define_domain_shape_tensorand_range_shape_tensor, which return the dynamic domain/range shapes of the operator. In general, subclasses should not define the methods_shapeor_shape_tensor. These have default implementations.If the subclassed operator has a non-scalar batch shape, it must also define
_batch_shapewhich returns the static batch shape. If the static batch shape is not always fully-defined, the subclass must also define_batch_shape_tensor, which returns the dynamic batch shape.- Parameters
dtype – The tf.dtypes.DType of the matrix that this operator represents.
is_non_singular – Expect that this operator is non-singular.
is_self_adjoint – Expect that this operator is equal to its Hermitian transpose. If
dtypeis real, this is equivalent to being symmetric.is_positive_definite – Expect that this operator is positive definite, meaning the quadratic form \(x^H A x\) has positive real part for all nonzero \(x\). Note that we do not require the operator to be self-adjoint to be positive-definite.
is_square – Expect that this operator acts like square [batch] matrices.
name – A name for this
LinearOperator.
Initialize the
LinearOperator. (deprecated arguments)Deprecated: SOME ARGUMENTS ARE DEPRECATED:
(graph_parents). They will be removed in a future version. Instructions for updating: Do not passgraph_parents. They will no longer be used.This is a private method for subclass use. Subclasses should copy-paste this ``__init__`` documentation.
- Parameters
dtype – The type of the this
LinearOperator. Arguments tomatmulandsolvewill have to be this type.graph_parents – (Deprecated) Python list of graph prerequisites of this
LinearOperatorTypically tensors that are passed during initializationis_non_singular – Expect that this operator is non-singular.
is_self_adjoint – Expect that this operator is equal to its hermitian transpose. If
dtypeis real, this is equivalent to being symmetric.is_positive_definite – Expect that this operator is positive definite, meaning the quadratic form
x^H A xhas positive real part for all nonzerox. Note that we do not require the operator to be self-adjoint to be positive-definite. See: https://en.wikipedia.org/wiki/Positive-definite_matrix#Extension_for_non-symmetric_matricesis_square – Expect that this operator acts like square [batch] matrices.
name – A name for this
LinearOperator.parameters – Python dict of parameters used to instantiate this
LinearOperator.
- Raises
ValueError – If any member of graph_parents is None or not a
Tensor.ValueError – If hints are set incorrectly.