def __call__(self, x, grad):
        """
        Get a new parameter value from the Adam algorithm.

        Parameters
        ----------
        x : ndarray
            input parameters to optimise
        grad : ndarray
            gradient of x

        Returns
        -------
        x_new : ndarray
            the new value for x
        """
        self.t += 1

        if self.m is None:
            self.m = np.zeros_like(x)
            self.v = np.zeros_like(x)

        self.m = self.beta1 * self.m + (1 - self.beta1) * grad
        self.v = self.beta2 * self.v + (1 - self.beta2) * grad**2
        mbar = self.m / (1 - self.beta1**self.t)
        vbar = self.v / (1 - self.beta2**self.t)

        x_new = x - self.alpha * mbar / (np.sqrt(vbar) + self.epsilon)
        return x_new
def __call__ ( self , x , grad ) : self . t += 1 if self . m is None : self . m = np . zeros_like ( x ) self . v = np . zeros_like ( x ) self . m = self . beta1 * self . m + ( 1 - self . beta1 ) * grad self . v = self . beta2 * self . v + ( 1 - self . beta2 ) * grad ** 2 mbar = self . m / ( 1 - self . beta1 ** self . t ) vbar = self . v / ( 1 - self . beta2 ** self . t ) x_new = x - self . alpha * mbar / ( np . sqrt ( vbar ) + self . epsilon ) return x_new
Get a new parameter value from the Adam algorithm.

        Parameters
        ----------
        x : ndarray
            input parameters to optimise
        grad : ndarray
            gradient of x

        Returns
        -------
        x_new : ndarray
            the new value for x