Gradient
In the previous example, the partial derivatives of x0 and x1 were calculated for each variable. Now, we want to calculate the partial derivatives of x0 and x1 collectively. For example, let's calculate the partial derivatives of (x0, x1) when x0 = 3
and x1 = 4
as ()The vector that collectively indicates the partial differentials of all the variables, such as () is called a gradient. You can implement a gradient as follows:
def numerical_gradient(f, x):     h = 1e-4 # 0.0001     grad = np.zeros_like(x) # Generate an array with the same shape as x     for idx in range(x.size):         tmp_val = x[idx]         # Calculate f(x+h)         x[idx] = tmp_val + h         fxh1 = f(x)         # Calculate f(x-h)...