『ゼロから作る Deep Learning』(オライリー・ジャパン)を勉強中です。
「ニューラルネットワークの学習」の章で、以下のような記述があります。
import numpy as np
import matplotlib.pylab as plt
def numerical_diff(f, x):
h = 1e-4
return (f(x+h) - f(x-h)) / (2*h)
def function_1(x):
return 0.01x**2 + 0.1x
numerical_diff(function_1,5)
0.1999999999990898
◎質問です。
def numerical_diff(f, x):
h = 1e-4
return (f(x+h) - f(x-h)) / (2*h)
微分が表現されているのは分かるのですが...
引数のfに違和感があります。
その違和感について 、うまく言えないのですが...たとえば、カンタンに、
def example(f,x):
return f(x)
として、このばあい、fは有効じゃないと、おもうんですよ。
なのに、なぜ、
def numerical_diff(f, x):
h = 1e-4
return (f(x+h) - f(x-h)) / (2*h)
なら、有効なのかという...
要は、fの働が謎なんです。ご説明いただけると幸いであります〜
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2019/06/30 09:13