apple / learning-subspaces
Conditional Complexity

The distribution of complexity of units (measured with McCabe index).

Intro
  • Conditional complexity (also called cyclomatic complexity) is a term used to measure the complexity of software. The term refers to the number of possible paths through a program function. A higher value ofter means higher maintenance and testing costs (infosecinstitute.com).
  • Conditional complexity is calculated by counting all conditions in the program that can affect the execution path (e.g. if statement, loops, switches, and/or operators, try and catch blocks...).
  • Conditional complexity is measured at the unit level (methods, functions...).
  • Units are classified in four categories based on the measured McCabe index: 1-5 (simple units), 6-10 (medium complex units), 11-25 (complex units), 26+ (very complex units).
Learn more...
Conditional Complexity Overall
  • There are 198 units with 3,808 lines of code in units (66.8% of code).
    • 1 very complex units (168 lines of code)
    • 1 complex units (112 lines of code)
    • 14 medium complex units (693 lines of code)
    • 19 simple units (925 lines of code)
    • 163 very simple units (1,910 lines of code)
4% | 2% | 18% | 24% | 50%
Legend:
51+
26-50
11-25
6-10
1-5
Alternative Visuals
Conditional Complexity per Extension
51+
26-50
11-25
6-10
1-5
py4% | 2% | 18% | 24% | 50%
Conditional Complexity per Logical Component
primary logical decomposition
51+
26-50
11-25
6-10
1-5
ROOT23% | 0% | 5% | 47% | 23%
trainers0% | 8% | 38% | 33% | 19%
viz0% | 0% | 45% | 14% | 39%
models0% | 0% | 3% | 6% | 90%
data0% | 0% | 0% | 34% | 65%
analyze_results/tinyimagenet0% | 0% | 0% | 0% | 100%
analyze_results/cifar0% | 0% | 0% | 0% | 100%
experiment_configs/imagenet0% | 0% | 0% | 0% | 100%
experiment_configs/tinyimagenet0% | 0% | 0% | 0% | 100%
experiment_configs/cifar100% | 0% | 0% | 0% | 100%
Most Complex Units
Top 20 most complex units
Unit# linesMcCabe index# params
def main()
in main.py
168 70 0
def train()
in trainers/train_one_dim_subspaces.py
112 35 6
def test()
in trainers/simplex_ensembles.py
83 20 5
def train()
in trainers/train_simplexes.py
58 19 6
def test()
in trainers/ensemble.py
89 15 5
def test()
in trainers/swa_endpoint_ensembles.py
59 14 5
def add_data_helper()
in viz/utils.py
53 14 7
def forward()
in models/modules.py
35 13 2
def test()
in trainers/average_weights.py
54 13 5
def test()
in trainers/random_average_weights_global.py
40 12 5
def test()
in trainers/random_average_weights_layerwise.py
40 12 5
def add()
in viz/utils.py
22 12 5
def swa_cyc_lr()
in schedulers.py
40 11 3
def test()
in trainers/random_average_weights_perweight.py
60 11 5
def query()
in viz/utils.py
25 11 7
def add_point()
in viz/utils.py
35 11 7
def get_stats()
in trainers/train_one_dim_subspaces.py
30 10 1
def test()
in trainers/eval_one_dim_subspaces_multigpu.py
120 9 5
def get_stats()
in trainers/train_simplexes.py
33 9 1
def update_bn()
in utils.py
23 9 3