Пример #1
0
    def test_prox_star(self):
        n = 10
        x = 3 * np.random.randn(n, 1)
        f = functions.norm_l1()
        f2 = functions.dummy()
        f2.prox = lambda x, T: functions._prox_star(f, x, T)
        gamma = np.random.rand()

        p1 = f.prox(x, gamma)
        p2 = functions._prox_star(f2, x, gamma)

        np.testing.assert_array_almost_equal(p1, p2)

        p1 = f.prox(x, gamma) - x
        p2 = -gamma * f2.prox(x / gamma, 1 / gamma)
        np.testing.assert_array_almost_equal(p1, p2)
Пример #2
0
    def _algo(self):
        # Forward steps (in both primal and dual spaces)
        y1 = self.sol - self.step * (self.smooth_funs[0].grad(self.sol) +
                                     self.Lt(self.dual_sol))
        y2 = self.dual_sol + self.step * self.L(self.sol)

        # Backward steps (in both primal and dual spaces)
        p1 = self.non_smooth_funs[0].prox(y1, self.step)
        p2 = _prox_star(self.non_smooth_funs[1], y2, self.step)

        # Forward steps (in both primal and dual spaces)
        q1 = p1 - self.step * (self.smooth_funs[0].grad(p1) + self.Lt(p2))
        q2 = p2 + self.step * self.L(p1)

        # Update solution (in both primal and dual spaces)
        self.sol[:] = self.sol - y1 + q1
        self.dual_sol[:] = self.dual_sol - y2 + q2
Пример #3
0
    def _algo(self):
        # Forward steps (in both primal and dual spaces)
        y1 = self.sol - self.step * (self.smooth_funs[0].grad(self.sol) +
                                     self.Lt(self.dual_sol))
        y2 = self.dual_sol + self.step * self.L(self.sol)

        # Backward steps (in both primal and dual spaces)
        p1 = self.non_smooth_funs[0].prox(y1, self.step)
        p2 = _prox_star(self.non_smooth_funs[1], y2, self.step)

        # Forward steps (in both primal and dual spaces)
        q1 = p1 - self.step * (self.smooth_funs[0].grad(p1) + self.Lt(p2))
        q2 = p2 + self.step * self.L(p1)

        # Update solution (in both primal and dual spaces)
        self.sol[:] = self.sol - y1 + q1
        self.dual_sol[:] = self.dual_sol - y2 + q2