Closed utsav-akhaury closed 3 years ago
ADMM in TensorFlow vs. ADMM in NumPy -
Update -
Running TF in eager mode speeds up the iteration drastically (although it's still slightly slower than NumPy on CPU)
I replaced all denoising & update steps by native TF functions to further optimize the code (instead of accessing the value of the tensor and performing operations on those arrays) [Eg - cv.GaussianBlur() -> tf.nn.conv2d]
I compared the NumPy and TF implementations function by function by giving random inputs and comparing the outputs in this notebook. The order of difference for all functions is very small (between 10-10 & 10-15)
All images were downscaled to speed up the code: 96 X 96 -> 64 X 64
The NumPy output oscillates and does not converge
The TF output also diverges and after 2000 iterations, the pixel values are not defined (NaN)
After upsampling by a factor of 4 to remove aliasing, the convergence is steeper (i.e. optimal reconstruction is achieved faster). But at the same time, the NumPy version diverges earlier (~300 iterations), while the TF version remains comparatively stable (until ~550 iterations)
By updating alpha (the gradient descent step size) after every iteration (as implemented here), the optimal solution is reached after a higher no. of iterations
Convergence achieved by updating the Gradient step size update (α) as given in Issue #3 Both NumPy and TensorFlow give similar results (order of difference ~10-4)
Code - https://github.com/utsav-akhaury/ADMM/blob/main/ADMM_tf.ipynb