aws-samples / deep-learning-models
Unit Size

The distribution of size of units (measured in lines of code).

Intro
  • Unit size measurements show the distribution of size of units of code (methods, functions...).
  • Units are classified in four categories based on their size (lines of code): 1-20 (small units), 20-50 (medium size units), 51-100 (long units), 101+ (very long units).
  • You should aim at keeping units small (< 20 lines). Long units may become "bloaters", code that have increased to such gargantuan proportions that they are hard to work with.
Learn more...
Unit Size Overall
  • There are 837 units with 13,402 lines of code in units (55.2% of code).
    • 9 very long units (1,696 lines of code)
    • 29 long units (1,908 lines of code)
    • 132 medium size units (4,264 lines of code)
    • 209 small units (3,181 lines of code)
    • 458 very small units (2,353 lines of code)
12% | 14% | 31% | 23% | 17%
Legend:
101+
51-100
21-50
11-20
1-10
Unit Size per Extension
101+
51-100
21-50
11-20
1-10
py12% | 14% | 31% | 23% | 17%
go0% | 0% | 48% | 51% | 0%
Unit Size per Logical Component
primary logical decomposition
101+
51-100
21-50
11-20
1-10
models/vision/classification17% | 9% | 27% | 30% | 14%
legacy/models/resnet23% | 5% | 26% | 27% | 17%
models/nlp/albert41% | 10% | 22% | 17% | 8%
models/vision/detection3% | 19% | 36% | 23% | 17%
ci/frcnn36% | 9% | 23% | 6% | 23%
models/nlp/electra68% | 0% | 11% | 11% | 9%
ci/albert76% | 0% | 13% | 7% | 3%
legacy/utils/tensorflow0% | 20% | 22% | 25% | 31%
models/nlp/t50% | 0% | 91% | 0% | 8%
models/nlp/common0% | 0% | 18% | 33% | 48%
legacy/hpc-cluster/monitor0% | 0% | 48% | 51% | 0%
Alternative Visuals
Longest Units
Top 20 longest units
Unit# linesMcCabe index# params
def main()
in models/nlp/albert/run_pretraining.py
248 42 0
def build_hrnet()
in models/vision/detection/awsdet/models/backbones/hrnet.py
245 3 2
def build_hrnet()
in models/vision/classification/models/hrnet.py
245 3 1
def upload_metrics()
in ci/frcnn/parse_and_submit.py
226 1 5
def main()
in models/nlp/electra/run_pretraining.py
220 30 0
def main()
in legacy/models/resnet/tensorflow/train_imagenet_resnet_hvd.py
162 36 0
def upload_metrics()
in ci/albert/parse_and_submit.py
130 1 5
def main()
in models/vision/classification/train_backbone.py
116 32 0
def cnn_model_function()
in legacy/models/resnet/tensorflow/train_imagenet_resnet_hvd.py
104 12 4
def _get_targets_single()
in models/vision/detection/awsdet/core/anchor/anchor_target.py
81 15 7
def call()
in models/vision/detection/awsdet/models/detectors/faster_rcnn.py
81 14 4
def eval_map()
in models/vision/detection/awsdet/core/evaluation/mean_ap.py
80 29 7
def main_sagemaker()
in models/vision/detection/tools/train.py
79 18 4
def _build_single_target()
in models/vision/detection/awsdet/core/bbox/bbox_target.py
79 12 5
def __init__()
in models/vision/detection/awsdet/models/bbox_heads/bbox_head.py
78 4 4
def main_ec2()
in models/vision/detection/tools/train.py
76 20 2
def ResNet()
in models/vision/classification/models/resnet_evo.py
74 21 14
def draw_boxes()
in models/vision/detection/awsdet/utils/visualize.py
73 2 7
def ResNet()
in models/vision/detection/awsdet/models/backbones/resnet_common.py
72 20 12
def __init__()
in models/vision/detection/awsdet/models/anchor_heads/retina_head.py
70 1 34