-
-
Save BundleOfKent/b9d82ebfeaa580e4e12886902b5ac30d to your computer and use it in GitHub Desktop.
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
N=1000 | |
hidden_0=50 | |
hidden_1=500 | |
contours= 21 | |
for j in range(100): | |
seed_=j | |
print("Seed: " + str(j)) | |
def costs(x,y,w_a,w_b): | |
np.random.seed(seed_) | |
w0=np.random.randn(hidden_0,784) | |
w1= np.random.randn(hidden_1,hidden_0) | |
w2=np.random.randn(10,hidden_1) | |
w1[5][5] = w_a | |
w1[5][6] = w_b | |
a0 = expit(w0 @ x.T) | |
a1= expit(w1@a0) | |
pred= expit(w2 @ a1) | |
return np.mean(np.sum((y.T-pred)**2,axis=0)) | |
m1s = np.linspace(-15, 17, 25) | |
m2s = np.linspace(-15, 18, 25) | |
M1, M2 = np.meshgrid(m1s, m2s) | |
zs = np.array([costs(X_train[0:N],y_train_oh[0:N] | |
,np.array([[mp1]]), np.array([[mp2]])) | |
for mp1, mp2 in zip(np.ravel(M1), np.ravel(M2))]) | |
Z = zs.reshape(M1.shape) | |
fig = plt.figure(figsize=(10,10)) | |
ax = fig.add_subplot(111,projection='3d' ) | |
ax.view_init(elev=40, azim=220) | |
ax.plot_surface(M1, M2, Z, cmap='terrain', #surface plot | |
antialiased=True,cstride=1,rstride=1, alpha=0.69) | |
plt.tight_layout() | |
plt.show() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment