「ゼロから作るDeep Learning ―Pythonで学ぶディープラーニングの理論と実装」を勉強しています。 4.3.2 数値微分の例 を読んでいて、内容は理解できたのですが、接線をプロットする gradient_1d.pyがわからなかったので、考えたメモです。 ソースコードは # coding: utf-8 import numpy as np import matplotlib.pylab as plt def numerical_diff(f, x): h = 1e-4 # 0.0001 return (f(x+h) - f(x-h)) / (2*h) def function_1(x): return 0.01*x**2 + 0.1*x def tangent_line(f, x): d = numerical_diff(f, x) print(d) y = f(x) - d*