Constructing a custom optimizer
The objective is to iteratively minimize the overall loss with the help of an optimization algorithm. In the paper by Gatys et al., optimization was done using the L-BFGS algorithm, which is an optimization algorithm based on Quasi-Newtonmethods, which are popularly used for solving non-linear optimization problems and parameter estimation. This method usually converges faster thanstandard gradient descent.
SciPy has an implementation available inscipy.optimize.fmin_l_bfgs_b()
; however, limitations include the function being applicable only to flat one-dimensional vectors, unlike three-dimensional image matrices that we are dealing with, and the fact that the value of loss function and gradients need to be passed as two separate functions. We build anEvaluator
class based on patterns, followed bykeras
creator François Chollet, to compute both loss and gradient values in one pass instead of independent and separate computations. This will return the loss value...