Open muhammadahsan opened 1 month ago
Hi Muhammad, thanks for reaching out to me. Can you provide more details about your setup? Have you executed the 'Netdissect' approach before executing the code? This step guarantees that the setup is correct. If you have already executed it, can you check your dataset directory and the settings on the 'settings.py' file?
Yes, I run Netdissect first, then feature_extraction_global.py Actually the below code is returning empty lists of activations_sum, activations_max, activations_avg:
// Function to extract values from the model for each image
activations_sum=[]
activations_max=[]
activations_avg=[]
def hook_fn(m, i, o):
unit_sum={}
unit_max={}
unit_avg={}
for grad in o:
try:
for i,j in enumerate(grad):
unit_sum[i+1]=j.sum().item()
##max
unit_max[i+1]=j.max().item()
##avg
unit_avg[i+1]=j.mean().item()
activations_sum.append(unit_sum)
activations_max.append(unit_max)
activations_avg.append(unit_avg)
except AttributeError:
print ("None found for Gradient")
//Layer that I'm going to use. After all, try to get all layers
layer = model._modules['layer4']
layer.register_forward_hook(hook_fn)
There are some points that you have to check:
getting empty files by Running "feature_extraction_global.py" to extract the global concepts. The resultant files contains only column names like; ,target,name