| 27 | |
| 28 | |
| 29 | def plot_his(inputs, inputs_norm): |
| 30 | # plot histogram for the inputs of every layer |
| 31 | for j, all_inputs in enumerate([inputs, inputs_norm]): |
| 32 | for i, input in enumerate(all_inputs): |
| 33 | plt.subplot(2, len(all_inputs), j*len(all_inputs)+(i+1)) |
| 34 | plt.cla() |
| 35 | if i == 0: |
| 36 | the_range = (-7, 10) |
| 37 | else: |
| 38 | the_range = (-1, 1) |
| 39 | plt.hist(input.ravel(), bins=15, range=the_range, color='#FF5733') |
| 40 | plt.yticks(()) |
| 41 | if j == 1: |
| 42 | plt.xticks(the_range) |
| 43 | else: |
| 44 | plt.xticks(()) |
| 45 | ax = plt.gca() |
| 46 | ax.spines['right'].set_color('none') |
| 47 | ax.spines['top'].set_color('none') |
| 48 | plt.title("%s normalizing" % ("Without" if j == 0 else "With")) |
| 49 | plt.draw() |
| 50 | plt.pause(0.01) |
| 51 | |
| 52 | |
| 53 | def built_net(xs, ys, norm): |