Replaced manual calculation with builtin numpy functions
This commit is contained in:
parent
cbb6036beb
commit
6af243efba
@ -55,13 +55,9 @@ class ProximalDecoder:
|
|||||||
# Calculate second term
|
# Calculate second term
|
||||||
|
|
||||||
for k, x_k in enumerate(x):
|
for k, x_k in enumerate(x):
|
||||||
# TODO: Perform the summation with np.sum()
|
|
||||||
sum_result = 0
|
sum_result = 0
|
||||||
for i in self._B[k]:
|
for i in self._B[k]:
|
||||||
prod = 1
|
prod = np.prod(x[self._A[i]])
|
||||||
for j in self._A[i]:
|
|
||||||
prod *= x[j]
|
|
||||||
|
|
||||||
sum_result += prod**2 - prod
|
sum_result += prod**2 - prod
|
||||||
|
|
||||||
term_2 = 2 / x_k * sum_result
|
term_2 = 2 / x_k * sum_result
|
||||||
@ -70,7 +66,7 @@ class ProximalDecoder:
|
|||||||
|
|
||||||
return np.array(result)
|
return np.array(result)
|
||||||
|
|
||||||
# TODO: Is this correct?
|
# TODO: Is the 'projection onto [-eta, eta]' actually just clipping?
|
||||||
def _projection(self, x):
|
def _projection(self, x):
|
||||||
"""Project a vector onto [-eta, eta]^n in order to avoid numerical instability.
|
"""Project a vector onto [-eta, eta]^n in order to avoid numerical instability.
|
||||||
Detailed in 3.2, p. 3 (Equation (15)).
|
Detailed in 3.2, p. 3 (Equation (15)).
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user