Avoid duplicate call of gradient function
When `self._t = 0`, exploits the calculation made at raw 182 and avoids recalculation.
This is reduces the number of calls made to the backend; extremely beneficial in algorithms where `self._maxiter = 1`, such as in `qiskit.aqua.algorithms.QGAN`.
let me copy you for information.
@@ -188,6 +188,7 @@ class ADAM(Optimizer):
params = params_new = initial_point
while self._t < self._maxiter:
+ if self._t > 0:
derivative = gradient_function(params)
self._t += 1
self._m = self._beta_1 * self._m + (1 - self._beta_1) * derivative
