import json, sys, numpy as np
%pylab inline
Populating the interactive namespace from numpy and matplotlib
#https://marcan.st/transf/scale2.0x_model.json
model = json.load(open("scale2.0x_model.json"))
for k,v in model[0].items():
print k
weight kH nOutputPlane bias kW nInputPlane
for l in model:
print np.array(l['weight']).shape
(32, 1, 3, 3) (32, 32, 3, 3) (64, 32, 3, 3) (64, 64, 3, 3) (128, 64, 3, 3) (128, 128, 3, 3) (1, 128, 3, 3)
for l in model:
ws=np.array(l['weight']).flatten()
num=len(ws)
nonzero=sum([1 if(abs(i)<0.001) else 0 for i in ws ])
print num,nonzero,float(nonzero)/num
288 2 0.00694444444444 9216 68 0.00737847222222 18432 176 0.00954861111111 36864 353 0.00957573784722 73728 775 0.0105116102431 147456 1711 0.0116034613715 1152 2 0.00173611111111
for l in model:
ws=np.array(l['weight']).flatten()
pylab.hist(ws)
pylab.show()