Created
February 26, 2018 08:17
-
-
Save jireh-father/d79547a523d755789958be5d1f3aff49 to your computer and use it in GitHub Desktop.
weight_initialization_variance_example
This file contains hidden or 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 | |
| # input x | |
| x = np.array([[1], [2], [3], [4], [5], [6], [7], [8], [9], [10]]) | |
| print("input x: %f" % x.var()) | |
| # high variance w1 | |
| w1 = np.random.randn(10, 10) | |
| w1[0][0] = 100 | |
| print("parameter w1 high variance : %f" % w1.var()) | |
| # low variance w2 | |
| w2 = np.random.randn(10, 10) | |
| print("parameter w2 low variance : %f" % w2.var()) | |
| # output1 with high variance input w1 | |
| h1 = np.dot(w1, x) | |
| print("output h1 by w1 : %f" % h1.var()) | |
| # output2 with high variance input w2 | |
| h2 = np.dot(w2, x) | |
| print("output h2 by w2 : %f" % h2.var()) | |
| h3 = np.dot(w1, np.dot(w1, np.dot(w1, x))) | |
| print("output h3 by w1 : %f" % h3.var()) | |
| h4 = np.dot(w2, np.dot(w2, np.dot(w2, x))) | |
| print("output h4 by w2 : %f" % h4.var()) | |
| ''' | |
| === pre processing === | |
| input x: 8.250000 | |
| parameter w1 high variance : 100.044956 | |
| parameter w2 low variance : 0.901882 | |
| === 1 layer nn feed forward === | |
| output h1 by w1 : 2006.573013 | |
| output h2 by w2 : 366.864624 | |
| === 3 layers nn feed forward === | |
| output h3 by w1 : 140190058599.812500 | |
| output h4 by w2 : 23940.654573 | |
| ''' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment