MCPcopy Create free account
hub / github.com/PeizeSun/SparseR-CNN / do_activation

Function do_activation

tools/analyze_model.py:52–72  ·  view source on GitHub ↗
(cfg)

Source from the content-addressed store, hash-verified

50
51
52def do_activation(cfg):
53 data_loader = build_detection_test_loader(cfg, cfg.DATASETS.TEST[0])
54 model = build_model(cfg)
55 DetectionCheckpointer(model).load(cfg.MODEL.WEIGHTS)
56 model.eval()
57
58 counts = Counter()
59 total_activations = []
60 for idx, data in zip(tqdm.trange(args.num_inputs), data_loader): # noqa
61 count = activation_count_operators(model, data)
62 counts += count
63 total_activations.append(sum(count.values()))
64 logger.info(
65 "(Million) Activations for Each Type of Operators:\n"
66 + str([(k, v / idx) for k, v in counts.items()])
67 )
68 logger.info(
69 "Total (Million) Activations: {}±{}".format(
70 np.mean(total_activations), np.std(total_activations)
71 )
72 )
73
74
75def do_parameter(cfg):

Callers

nothing calls this directly

Calls 5

build_modelFunction · 0.90
loadMethod · 0.80

Tested by

no test coverage detected