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。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。
