Created
October 28, 2018 21:35
-
-
Save kcha4github/928f7937daff8ca587df07a26d25b87b to your computer and use it in GitHub Desktop.
ゼロから作るDeep Learning 4.3.3 偏微分のグラフ
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
import matplotlib.pylab as plt | |
# 4.3.3 | |
# 関数 f(x0, x1) = x0 ** 2 + x1 ** 2 の実装:2変数関数であることに注意 | |
# 引数に numpy 配列を想定 | |
def function_2(x): | |
return x[0] ** 2 + x[1] ** 2 | |
from mpl_toolkits.mplot3d import Axes3D | |
x0 = np.arange(-3, 3, 0.1) | |
x1 = np.arange(-3, 3, 0.1) | |
X0, X1 = np.meshgrid(x0, x1) | |
y = function_2(np.array([X0, X1])) | |
fig = plt.figure() | |
ax = Axes3D(fig) | |
ax.set_xlabel("x0") | |
ax.set_ylabel("x1") | |
ax.set_zlabel("f(x0, x1)") | |
ax.plot_wireframe(X0, X1, y) | |
plt.show() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment