Hi all, I have a 3D matrix variable x(row, col, slice). And I want to calculate the sum of each slice 2D total variation. But cvxpy.reshape can only support to get a 2D matrix. Now I use a for loop to get the sum. Following is the code.
x = cp.Variable((row*col, slice))
sumtemp=cp.sum_squares(x-k)
for i in range(slice):
sumtemp = sumtemp + cp.tv(cp.reshape(x[:,j],(row,col),'C'))
objective = cp.Minimize(sumtemp)
constraints = [0 <= x]
prob = cp.Problem(objective, constraints)
result = prob.solve(verbose=False)
I wonder if it’s possible to use a matrix/list of matrix to speed up the calculation. I know cvxpy.vstack can get a list, but don’t know how to use it in my problem.
Thank you all!