我正在寻找一种Python Lasso求解器,它可以处理复数以用于波束成形问题。目标函数是仿射,XW - Y.我相信至少有一个这样的求解器是为Matlab实现的,
http://www.cs.ubc.ca/~schmidtm/Software/code.html
根据
的建议,我尝试使用scikit-learn MultiTaskLassoIs it possible to use complex numbers as target labels in scikit learn?
MultiTaskLasso中的矩阵21范数是处理复数的L1范数的正确方法。然而,我的方法需要一些体操来迫使求解者遵循复杂乘法的规则。基本上,我需要最小化
的L2规范[Re {X},Im {X}] * [[Re {W},Im {W}],[ - Im {W},Re {W}]] - [Re {Y},Im { Y}]
我试图通过向X矩阵添加另一行来实施W的两列之间的关系,[-Im {X},Re {X}]和行[-Im {Y},Re {Y理想情况下,将W的每一列的值与另一列中的相应值相等的成本等于
import numpy as np
import matplotlib.pyplot as plt
from sklearn.linear_model import MultiTaskLasso
# experiment specifications
numEl = 20
numLook = 1e2
arrayPosition = np.arange(numEl) * np.pi
thetaLook = np.r_[0 : np.pi : numLook * 1j] - (np.pi / 2)
thetaSource = -0.3758
# Make grid of look vectors
W = np.exp(1j * np.sin(thetaLook)[:,None] * arrayPosition)
data = np.exp(1j * np.sin(thetaSource) * arrayPosition).T
# Bartlet beamformer
bartlet = np.abs(np.dot(W.conj(), data))**2
B_bart = 10 * np.log10(np.abs(bartlet)); B_bart-=np.max(B_bart)
# Lasso setup
X = W.T
XSplit = np.vstack((np.hstack((X.real, X.imag)),\
np.hstack((-X.imag, X.real))))
YSplit = np.hstack((np.vstack((data.real, data.imag)),\
np.vstack((-data.imag, data.real)))).T
lasso_solver = MultiTaskLasso(alpha=0.1)
lasso = lasso_solver.fit(XSplit, YSplit).coef_
# Manipulate result back into complex values
stack1 = np.squeeze(lasso[0,:])
stack1 = np.squeeze(stack1[:numLook] + 1j * stack1[numLook:])
B_lasso = 10 * np.log10(np.abs(stack1) + np.spacing(1)); B_lasso -= np.max(B_lasso)
# stack1 ?= stack2 (Should be exact)
stack2 = np.squeeze(lasso[1,:])
stack2 = np.squeeze(-1j * stack2[:numLook] + stack2[numLook:])
np.testing.assert_almost_equal(stack1, stack2, decimal=1)
# Plot both beamformer results
_ = plt.plot(np.rad2deg(thetaLook), B_bart)
_ = plt.plot(np.rad2deg(thetaLook), B_lasso, 'r.')
_ = plt.ylim(-40,3); plt.ylabel('Beamformer Output, dB')
_ = plt.xlabel('Look Direction, deg')
虽然这种方法似乎适用于上述的简单问题,但当问题变得更复杂时,它会失败。当W的第一列和第二列之间的关系不再成立时,我定义了失败。在上面的示例中,创建小的不同行为的一种简单方法是将Ridge求解器替换为MultiTaskLasso。
有没有人知道一个Lasso求解器可以通过严格处理复数来解决复杂的价值问题?