Pythonによる勾配降下法の実装 - u++の備忘録ã®è¨äºã§ã以ä¸ã®ãããªå³ãä½æããã
y軸ã®ã©ãã«ã¯æ¨ªãåãã¦ãããããã§å ¨ãåé¡ãªãã®ã ããã©ãã«ã®åããå¤ãããå ´åã«ã¯ã次ã®ããã«"rotation"ã®ãªãã·ã§ã³ãæå®ããã°è¯ãã
import numpy as np import matplotlib.pyplot as plt def J(x): return x*(x-4)+5 n = 100 x = np.linspace(0, 5, n) np.random.seed(seed = 32) stack = [] # ããããç¨ã®ãªã¹ã # Graph plt.xlim(-1, 6) plt.ylim(-1, 8) plt.xlabel(r"$\omega$") plt.ylabel(r"$J(\omega)$", rotation=0) plt.plot(x, J(x), "b") plt.show()