Open YNawal opened 3 years ago
I am not so sure what you mean by "appropriate"? I guess, what you can do is, look into all the layers of a model and pick one to visualise. If you want the end result, pick one of the final layers.
Small script to get all the layers of a model:
import argparse
from mmaction.apis import init_recognizer
def parse_args():
parser = argparse.ArgumentParser(prog='model layer printer')
parser.add_argument('config', help='config file path')
parser.add_argument('checkpoint', help='checkpoint file')
parser.add_argument(
'--device', type=str, default='cuda:0', help='CPU/CUDA device option')
args = parser.parse_args()
return args
def print_layers(model, layer_name):
if len(model._modules) == 0:
print(layer_name)
else:
for key in model._modules:
name = key if len(layer_name) == 0 else layer_name + '/' + key
print_layers(model._modules[key], name)
def main():
args = parse_args()
model = init_recognizer(args.config, args.checkpoint, device=args.device)
print_layers(model, '')
if __name__ == '__main__':
main()
get_flops.py does sth similar.
Ref. #903
@rlleshi Thnaks for your reply My problem now is how we can plot the self attentions as in vision transformer or grad cam in other models.
Hi @YNawal can you do this? if yes, can you give me a little advice? thank you.
Hello everybody Please what is the appropriate target layer name to visualise the grad cam of a video Thanks for your help