Created
June 13, 2014 13:22
-
-
Save ryo1kato/6f3f53d60842c69a392d to your computer and use it in GitHub Desktop.
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
| #!/usr/bin/python | |
| import sys | |
| NR_LAYER = 10 | |
| def get_n_plus_1(weights): | |
| length = len(weights) | |
| lower_weights = [[1 for col in range(length+1)] for row in range(length+1)] | |
| print "---- %d -----" % len(weights) | |
| for x in range(0,length): | |
| for y in range(0,length): | |
| #print weights[x][y] | |
| qw = weights[x][y] / 4.0 # quarter of weight | |
| lower_weights[x] [y] += qw | |
| lower_weights[x+1][y] += qw | |
| lower_weights[x] [y+1] += qw | |
| lower_weights[x+1][y+1] += qw | |
| return lower_weights | |
| layers = [] | |
| layers.append([[1.0]]) | |
| for i in range(0,NR_LAYER): | |
| layers.append( get_n_plus_1(layers[i]) ) | |
| i=1 | |
| for l in layers: | |
| total = 0 | |
| for x in l: | |
| for y in x: | |
| sys.stdout.write("%.2f " % y) | |
| total += y | |
| sys.stdout.write("\n") | |
| print "============ layer%d: %.2f =============" % (i, total) | |
| i+=1 | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment