LinearOperator 就像一个块循环矩阵。
继承自:LinearOperator,Module
用法
tf.linalg.LinearOperatorCirculant2D(
spectrum, input_output_dtype=tf.dtypes.complex64, is_non_singular=None,
is_self_adjoint=None, is_positive_definite=None, is_square=True,
name='LinearOperatorCirculant2D'
)参数
-
spectrum形状[B1,...,Bb, N]Tensor。允许的数据类型:float16,float32,float64,complex64,complex128。类型可以不同于input_output_dtype -
input_output_dtypedtype用于输入/输出。 -
is_non_singular期望这个运算符是非奇异的。 -
is_self_adjoint期望这个算子等于它的厄米转置。如果spectrum是真实的,这将永远是真实的。 -
is_positive_definite期望这个算子是正定的,意思是二次形式x^H A x对所有非零具有正实部x.请注意,我们不要求算子自伴是正定的。看:https://en.wikipedia.org/wiki/Positive-definite_matrix
#Extension_for_non_symmetric_matrices -
is_square期望此运算符的行为类似于方形 [batch] 矩阵。 -
name附加到此类创建的所有操作的名称。
属性
-
H返回当前的伴随LinearOperator.给定
A表示此LinearOperator,返回A*。请注意,调用self.adjoint()和self.H是等效的。 -
batch_shapeTensorShape这批尺寸的LinearOperator.如果此运算符的作用类似于带有
A.shape = [B1,...,Bb, M, N]的批处理矩阵A,则返回TensorShape([B1,...,Bb]),相当于A.shape[:-2] -
block_depth递归定义的循环块的深度定义了这个Operator.使用
A这个Operator的密集表示,block_depth = 1表示A是对称循环。例如,A = |w z y x| |x w z y| |y x w z| |z y x w|block_depth = 2表示A是具有对称循环块的块对称循环。例如,使用W,X,Y,Z对称循环,A = |W Z Y X| |X W Z Y| |Y X W Z| |Z Y X W|block_depth = 3表示A是块对称循环,块对称循环块。 -
block_shape -
domain_dimension此运算符的域的维度(在向量空间的意义上)。如果此运算符的作用类似于带有
A.shape = [B1,...,Bb, M, N]的批处理矩阵A,则返回N。 -
dtypeTensor的DType由此LinearOperator处理。 -
graph_parents这个的图依赖列表LinearOperator. (已弃用)警告:此函数已弃用。它将在未来的版本中删除。更新说明:请勿调用
graph_parents。 -
is_non_singular -
is_positive_definite -
is_self_adjoint -
is_square返回True/False取决于此运算符是否为正方形。 -
parameters用于实例化此LinearOperator的参数字典。 -
range_dimension此运算符范围的维度(在向量空间的意义上)。如果此运算符的作用类似于带有
A.shape = [B1,...,Bb, M, N]的批处理矩阵A,则返回M。 -
shapeTensorShape这个的LinearOperator.如果此运算符的作用类似于带有
A.shape = [B1,...,Bb, M, N]的批处理矩阵A,则返回TensorShape([B1,...,Bb, M, N]),等效于A.shape。 -
spectrum -
tensor_rank与此运算符对应的矩阵的秩(在张量的意义上)。如果此运算符的作用类似于带有
A.shape = [B1,...,Bb, M, N]的批处理矩阵A,则返回b + 2。
该运算符的作用类似于块循环矩阵 A ,对于某些 b >= 0 ,其形状为 [B1,...,Bb, N, N] 。第一个 b 索引索引批处理成员。对于每个批次索引 (i1,...,ib) , A[i1,...,ib,::] 是一个 N x N 矩阵。此矩阵A 未具体化,但为了广播此形状将是相关的。
块循环矩阵的说明
如果A是块循环,块大小为N0, N1(N0 * N1 = N):A具有块循环结构,由N0 x N0块组成,每个块都有一个N1 x N1循环矩阵。
例如,每个循环使用W , X , Y , Z,
A = |W Z Y X|
|X W Z Y|
|Y X W Z|
|Z Y X W|
请注意,A 本身通常不会循环使用。
频谱方面的说明
在 [batch] 频谱 H 和傅里叶变换方面有一个等效的说明。这里我们考虑A.shape = [N, N] 并忽略批量维度。
If H.shape = [N0, N1] , ( N0 * N1 = N ): 粗略地说,矩阵乘法等于傅里叶乘法器的作用:A u = IDFT2[ H DFT2[u] ]。准确地说,给定 [N, R] 矩阵 u ,让 DFT2[u] 是通过将 u 重新整形为 [N0, N1, R] 并在前两个维度上进行二维 DFT 定义的 [N0, N1, R] Tensor。让 IDFT2 是 DFT2 的倒数。矩阵乘法可以按列表示:
(A u)_r = IDFT2[ H * (DFT2[u])_r ]
从谱中推导出算子属性。
- 此运算符是正定的当且仅当
Real{H} > 0。
傅立叶变换的一般性质是厄米特函数和实值变换之间的对应关系。
假设 H.shape = [B1,...,Bb, N0, N1] ,我们说 H 是 Hermitian 谱,如果 % 表示模除,
H[..., n0 % N0, n1 % N1] = ComplexConjugate[ H[..., (-n0) % N0, (-n1) % N1 ].
- 当且仅当
H是 Hermitian 时,此运算符对应于实矩阵。 - 当且仅当
H为实数时,此运算符是自伴的。
参见例如“Discrete-Time 信号处理”,奥本海姆和谢弗。
自伴正定算子示例
# spectrum is real ==> operator is self-adjoint
# spectrum is positive ==> operator is positive definite
spectrum = [[1., 2., 3.],
[4., 5., 6.],
[7., 8., 9.]]
operator = LinearOperatorCirculant2D(spectrum)
# IFFT[spectrum]
operator.convolution_kernel()
==> [[5.0+0.0j, -0.5-.3j, -0.5+.3j],
[-1.5-.9j, 0, 0],
[-1.5+.9j, 0, 0]]
operator.to_dense()
==> Complex self adjoint 9 x 9 matrix.
根据实际卷积核定义的示例,
# convolution_kernel is real ==> spectrum is Hermitian.
convolution_kernel = [[1., 2., 1.], [5., -1., 1.]]
spectrum = tf.signal.fft2d(tf.cast(convolution_kernel, tf.complex64))
# spectrum is shape [2, 3] ==> operator is shape [6, 6]
# spectrum is Hermitian ==> operator is real.
operator = LinearOperatorCirculant2D(spectrum, input_output_dtype=tf.float32)
性能
假设 operator 是形状为 [N, N] 和 x.shape = [N, R] 的 LinearOperatorCirculant。然后
operator.matmul(x)是O(R*N*Log[N])operator.solve(x)是O(R*N*Log[N])operator.determinant()涉及大小Nreduce_prod。
如果相反 operator 和 x 具有形状 [B1,...,Bb, N, N] 和 [B1,...,Bb, N, R] ,则每个操作的复杂性都会增加 B1*...*Bb 。
矩阵属性提示
此 LinearOperator 使用 is_X 形式的布尔标志初始化,用于 X = non_singular, self_adjoint, positive_definite, square 。这些具有以下含义
- 如果
is_X == True,调用者应该期望操作符具有属性X。这是一个应该实现的承诺,但不是运行时断言。例如,有限的浮点精度可能会导致违反这些承诺。 - 如果
is_X == False,调用者应该期望操作符没有X。 - 如果
is_X == None(默认),调用者应该没有任何期望。
相关用法
- Python tf.linalg.LinearOperatorCirculant2D.solve用法及代码示例
- Python tf.linalg.LinearOperatorCirculant2D.assert_non_singular用法及代码示例
- Python tf.linalg.LinearOperatorCirculant2D.matvec用法及代码示例
- Python tf.linalg.LinearOperatorCirculant2D.matmul用法及代码示例
- Python tf.linalg.LinearOperatorCirculant2D.solvevec用法及代码示例
- Python tf.linalg.LinearOperatorCirculant2D.diag_part用法及代码示例
- Python tf.linalg.LinearOperatorCirculant3D.diag_part用法及代码示例
- Python tf.linalg.LinearOperatorCirculant.matvec用法及代码示例
- Python tf.linalg.LinearOperatorCirculant3D.solvevec用法及代码示例
- Python tf.linalg.LinearOperatorCirculant3D.matvec用法及代码示例
- Python tf.linalg.LinearOperatorCirculant.diag_part用法及代码示例
- Python tf.linalg.LinearOperatorCirculant.assert_non_singular用法及代码示例
- Python tf.linalg.LinearOperatorCirculant3D.assert_non_singular用法及代码示例
- Python tf.linalg.LinearOperatorCirculant3D.matmul用法及代码示例
- Python tf.linalg.LinearOperatorCirculant用法及代码示例
- Python tf.linalg.LinearOperatorCirculant3D.solve用法及代码示例
- Python tf.linalg.LinearOperatorCirculant.solve用法及代码示例
- Python tf.linalg.LinearOperatorCirculant.solvevec用法及代码示例
- Python tf.linalg.LinearOperatorCirculant.matmul用法及代码示例
- Python tf.linalg.LinearOperatorCirculant3D用法及代码示例
注:本文由纯净天空筛选整理自tensorflow.org大神的英文原创作品 tf.linalg.LinearOperatorCirculant2D。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。
