Moved calculation of A and B sets from ProximalDecoder::_grad_h() to ProximalDecoder::__init__()
This commit is contained in:
parent
296feaf1fb
commit
d129a222bc
@ -27,6 +27,17 @@ class ProximalDecoder:
|
|||||||
self._gamma = gamma
|
self._gamma = gamma
|
||||||
self._eta = eta
|
self._eta = eta
|
||||||
|
|
||||||
|
self._A = []
|
||||||
|
self._B = []
|
||||||
|
|
||||||
|
for row in self._H:
|
||||||
|
A_k = np.argwhere(row == 1)
|
||||||
|
self._A.append(A_k[:, 0])
|
||||||
|
|
||||||
|
for column in self._H.T:
|
||||||
|
B_k = np.argwhere(column == 1)
|
||||||
|
self._B.append(B_k[:, 0])
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def _L_awgn(s: np.array, y: np.array) -> np.array:
|
def _L_awgn(s: np.array, y: np.array) -> np.array:
|
||||||
"""Variation of the negative log-likelihood for the special case of AWGN noise.
|
"""Variation of the negative log-likelihood for the special case of AWGN noise.
|
||||||
@ -44,19 +55,11 @@ class ProximalDecoder:
|
|||||||
# Calculate second term
|
# Calculate second term
|
||||||
|
|
||||||
for k, x_k in enumerate(x):
|
for k, x_k in enumerate(x):
|
||||||
# TODO: Perform this operation for each row simultaneously
|
|
||||||
B_k = np.argwhere(self._H[:, k] == 1)
|
|
||||||
B_k = B_k[:, 0] # Get rid of one layer of arrays
|
|
||||||
|
|
||||||
# TODO: Perform the summation with np.sum()
|
# TODO: Perform the summation with np.sum()
|
||||||
sum_result = 0
|
sum_result = 0
|
||||||
for i in B_k:
|
for i in self._B[k]:
|
||||||
# TODO: Perform this operation for each column simultaneously
|
|
||||||
A_i = np.argwhere(self._H[i] == 1)
|
|
||||||
A_i = A_i[:, 0] # Get rid of one layer of arrays
|
|
||||||
|
|
||||||
prod = 1
|
prod = 1
|
||||||
for j in A_i:
|
for j in self._A[i]:
|
||||||
prod *= x[j]
|
prod *= x[j]
|
||||||
|
|
||||||
sum_result += prod**2 - prod
|
sum_result += prod**2 - prod
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user