Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
distiller
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
llvm
distiller
Commits
e65ec8fc
Commit
e65ec8fc
authored
5 years ago
by
Guy Jacob
Browse files
Options
Downloads
Patches
Plain Diff
Add experiment details in AlexNet BN yamls (FP32 and DoReFa)
parent
8d87e405
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
examples/quantization/fp32_baselines/alexnet_bn_base_fp32.yaml
+26
-0
26 additions, 0 deletions
...les/quantization/fp32_baselines/alexnet_bn_base_fp32.yaml
examples/quantization/quant_aware_train/alexnet_bn_dorefa.yaml
+33
-1
33 additions, 1 deletion
...les/quantization/quant_aware_train/alexnet_bn_dorefa.yaml
with
59 additions
and
1 deletion
examples/quantization/fp32_baselines/alexnet_bn_base_fp32.yaml
+
26
−
0
View file @
e65ec8fc
# Scheduler for training a FP32 baseline of AlexNet with Batch-Norm
#
# IMPORTANT NOTES:
# ----------------
# 1. Pay attention that this is not the original AlexNet, but AlexNet w. batch normalization layers.
# See model implementation in <distiller-root>/distiller/models/imagenet/alexnet_batchnorm.py
# 2. The best results are achieved with the Adam optimizer. As is, the optimizer used in the image classification
# sample is SGD and this is not configurable. So we need to edit the code:
# * Open <distiller-root>/distiller/apputils/image_classifier.py
# * In the function "_init_learner(args)", find the following snippet:
# optimizer = torch.optim.SGD(model.parameters(),
# lr=args.lr, momentum=args.momentum, weight_decay=args.weight_decay)
# And replace it with:
# optimizer = torch.optim.Adam(model.parameters(), lr=args.lr, weight_decay=args.weight_decay)
#
# Command line for training (running from the compress_classifier.py directory):
# python compress_classifier.py --arch alexnet_bn <path_to_imagenet_dataset> -p=50 --epochs=110 --compress=../quantization/fp32_baselines/alexnet_bn_base_fp32.yaml -j 22 --lr 0.0002 --wd 0.0001 --vs 0
#
# After 110 epochs we get:
# --- test ---------------------
# 50000 samples (256 per mini-batch)
# Test: [ 50/ 195] Loss 1.608579 Top1 61.757812 Top5 83.789062
# Test: [ 100/ 195] Loss 1.605091 Top1 61.964844 Top5 83.988281
# Test: [ 150/ 195] Loss 1.612654 Top1 61.950521 Top5 83.864583
# ==> Top1: 61.914 Top5: 83.838 Loss: 1.618
lr_schedulers
:
lr_schedulers
:
training_lr
:
training_lr
:
class
:
MultiStepLR
class
:
MultiStepLR
...
...
This diff is collapsed.
Click to expand it.
examples/quantization/quant_aware_train/alexnet_bn_dorefa.yaml
+
33
−
1
View file @
e65ec8fc
# Scheduler for training AlexNet with Batch-Norm, quantized using the DoReFa scheme
# Activations: 8-bits, Weights: 4-bits
# See:
# https://nervanasystems.github.io/distiller/algo_quantization/index.html#dorefa
# https://arxiv.org/abs/1606.06160
#
# IMPORTANT NOTES:
# ----------------
# 1. Pay attention that this is not the original AlexNet, but AlexNet w. batch normalization layers.
# See model implementation in <distiller-root>/distiller/models/imagenet/alexnet_batchnorm.py
# 2. The best results are achieved with the Adam optimizer. As is, the optimizer used in the image classification
# sample is SGD and this is not configurable. So we need to edit the code:
# * Open <distiller-root>/distiller/apputils/image_classifier.py
# * In the function "_init_learner(args)", find the following snippet:
# optimizer = torch.optim.SGD(model.parameters(),
# lr=args.lr, momentum=args.momentum, weight_decay=args.weight_decay)
# And replace it with:
# optimizer = torch.optim.Adam(model.parameters(), lr=args.lr, weight_decay=args.weight_decay)
#
# Command line for training (running from the compress_classifier.py directory):
# python compress_classifier.py --arch alexnet_bn <path_to_imagenet_dataset> -p=50 --epochs=110 --compress=../quantization/quant_aware_train/alexnet_bn_dorefa.yaml -j 22 --lr 0.0002 --wd 0.0001 --vs 0
#
# After 110 epochs we get:
# --- test ---------------------
# 50000 samples (256 per mini-batch)
# Test: [ 50/ 195] Loss 1.645975 Top1 61.453125 Top5 83.437500
# Test: [ 100/ 195] Loss 1.635810 Top1 61.507812 Top5 83.445312
# Test: [ 150/ 195] Loss 1.633975 Top1 61.479167 Top5 83.419271
# ==> Top1: 61.498 Top5: 83.454 Loss: 1.635
#
# So that's 61.498%, compared to 61.914% for the FP32 model
quantizers
:
quantizers
:
dorefa_quantizer
:
dorefa_quantizer
:
class
:
DorefaQuantizer
class
:
DorefaQuantizer
bits_activations
:
8
bits_activations
:
8
bits_weights
:
3
bits_weights
:
4
overrides
:
overrides
:
# Don't quantize first and last layer
# Don't quantize first and last layer
features.0
:
features.0
:
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment