The proximal gradient method handles a smooth loss plus a "rough" term by taking a gradient step and then applying a proximal operator (Murphy, Probabilistic Machine Learning). Implement five functions; all return new float arrays.
project_box(theta, l, u): the projection onto . l and u are scalars or arrays and may be infinite.
projected_gd(grad, theta0, l, u, eta, n_iter): run for n_iter iterations from theta0 and return the final .
For the binary set use everywhere below.
binaryconnect_step(theta, grad, eta): the straight-through update: evaluate the gradient at the quantized parameters but update the real-valued : return .
proxquant_prox(theta, lam): the proximal operator of , a soft threshold toward the nearest of :
where the inner of a zero difference is (that term vanishes).
proxquant_step(theta, grad, eta, lam): one ProxQuant step: proxquant_prox(theta - eta * grad(theta), lam).
Here grad is a function returning at a given parameter vector.