so that I can plot out the saliencies for all layers and every 8 filters in the vgg net. Here is what I did, but the function compilation stage is prohibitively slow. It seems to me that the gradient loop did not properly exploit the stacked structure of the vgg net and has to go through the graph every single time.
def compile_saliency_function1(net,layernamelist,layershapelist,scalefactor):
inp = net['input'].input_var
outp = lasagne.layers.get_output([net[layername] for layername in layernamelist], deterministic=True)
saliencyfnlist=[]
for layeri in range(len(layernamelist)):
filtercount=int(layershapelist[layeri]/scalefactor)
filterindices=[ii*scalefactor for ii in range(filtercount)]
layeroutp=outp[layeri]
saliencylayerlist=[]
for filterindex in filterindices:
max_outpi=layeroutp[0,filterindex,]
saliencylayerlist.append(theano.grad(max_outpi.sum(), wrt=inp))
print(len(saliencylayerlist))
layerfnlist=theano.function([inp], saliencylayerlist)
saliencyfnlist.append([layerfnlist])
return saliencyfnlist
starttime=time.time()
saliencyfntuple=compile_saliency_function1(net,['conv5_1','conv5_2','conv5_3'],[512,512,512],8)
print('fn time',time.time()-starttime)
Hi, I am currently modifying the saliency maps of
https://github.com/Lasagne/Recipes/blob/master/examples/Saliency%20Maps%20and%20Guided%20Backpropagation.ipynb
so that I can plot out the saliencies for all layers and every 8 filters in the vgg net. Here is what I did, but the function compilation stage is prohibitively slow. It seems to me that the gradient loop did not properly exploit the stacked structure of the vgg net and has to go through the graph every single time.
I am just wondering is there a better way to do it? Thanks!