# Image classification reference training scripts
This folder contains reference training scripts for image classification.
They serve as a log of how to train specific models, as provide baseline
training and evaluation scripts to quickly bootstrap research.
Except otherwise noted, all models have been trained on 8x V100 GPUs with
the following parameters:
| Parameter | value |
| ------------------------ | ------ |
| `--batch_size` | `32` |
| `--epochs` | `90` |
| `--lr` | `0.1` |
| `--momentum` | `0.9` |
| `--wd`, `--weight-decay` | `1e-4` |
| `--lr-step-size` | `30` |
| `--lr-gamma` | `0.1` |
### AlexNet and VGG
Since `AlexNet` and the original `VGG` architectures do not include batch
normalization, the default initial learning rate `--lr 0.1` is to high.
```
python main.py --model $MODEL --lr 1e-2
```
Here `$MODEL` is one of `alexnet`, `vgg11`, `vgg13`, `vgg16` or `vgg19`. Note
that `vgg11_bn`, `vgg13_bn`, `vgg16_bn`, and `vgg19_bn` include batch
normalization and thus are trained with the default parameters.
### ResNext-50 32x4d
```
python -m torch.distributed.launch --nproc_per_node=8 --use_env train.py\
--model resnext50_32x4d --epochs 100
```
### ResNext-101 32x8d
On 8 nodes, each with 8 GPUs (for a total of 64 GPUS)
```
python -m torch.distributed.launch --nproc_per_node=8 --use_env train.py\
--model resnext101_32x8d --epochs 100
```
### MobileNetV2
```
python -m torch.distributed.launch --nproc_per_node=8 --use_env train.py\
--model mobilenet_v2 --epochs 300 --lr 0.045 --wd 0.00004\
--lr-step-size 1 --lr-gamma 0.98
```
### MobileNetV3 Large & Small
```
python -m torch.distributed.launch --nproc_per_node=8 --use_env train.py\
--model $MODEL --epochs 600 --opt rmsprop --batch-size 128 --lr 0.064\
--wd 0.00001 --lr-step-size 2 --lr-gamma 0.973 --auto-augment imagenet --random-erase 0.2
```
Here `$MODEL` is one of `mobilenet_v3_large` or `mobilenet_v3_small`.
Then we averaged the parameters of the last 3 checkpoints that improved the Acc@1. See [#3182](https://github.com/pytorch/vision/pull/3182)
and [#3354](https://github.com/pytorch/vision/pull/3354) for details.
## Mixed precision training
Automatic Mixed Precision (AMP) training on GPU for Pytorch can be enabled with the [NVIDIA Apex extension](https://github.com/NVIDIA/apex).
Mixed precision training makes use of both FP32 and FP16 precisions where appropriate. FP16 operations can leverage the Tensor cores on NVIDIA GPUs (Volta, Turing or newer architectures) for improved throughput, generally without loss in model accuracy. Mixed precision training also often allows larger batch sizes. GPU automatic mixed precision training for Pytorch Vision can be enabled via the flag value `--apex=True`.
```
python -m torch.distributed.launch --nproc_per_node=8 --use_env train.py\
--model resnext50_32x4d --epochs 100 --apex
```
## Quantized
### Parameters used for generating quantized models:
For all post training quantized models (All quantized models except mobilenet-v2), the settings are:
1. num_calibration_batches: 32
2. num_workers: 16
3. batch_size: 32
4. eval_batch_size: 128
5. backend: 'fbgemm'
```
python train_quantization.py --device='cpu' --post-training-quantize --backend='fbgemm' --model='<model_name>'
```
For Mobilenet-v2, the model was trained with quantization aware training, the settings used are:
1. num_workers: 16
2. batch_size: 32
3. eval_batch_size: 128
4. backend: 'qnnpack'
5. learning-rate: 0.0001
6. num_epochs: 90
7. num_observer_update_epochs:4
8. num_batch_norm_update_epochs:3
9. momentum: 0.9
10. lr_step_size:30
11. lr_gamma: 0.1
12. weight-decay: 0.0001
```
python -m torch.distributed.launch --nproc_per_node=8 --use_env train_quantization.py --model='mobilenet_v2'
```
Training converges at about 10 epochs.
For Mobilenet-v3 Large, the model was trained with quantization aware training, the settings used are:
1. num_workers: 16
2. batch_size: 32
3. eval_batch_size: 128
4. backend: 'qnnpack'
5. learning-rate: 0.001
6. num_epochs: 90
7. num_observer_update_epochs:4
8. num_batch_norm_update_epochs:3
9. momentum: 0.9
10. lr_step_size:30
11. lr_gamma: 0.1
12. weight-decay: 0.00001
```
python -m torch.distributed.launch --nproc_per_node=8 --use_env train_quantization.py --model='mobilenet_v3_large' \
--wd 0.00001 --lr 0.001
```
For post training quant, device is set to CPU. For training, the device is set to CUDA.
### Command to evaluate quantized models using the pre-trained weights:
```
python train_quantization.py --device='cpu' --test-only --backend='<backend>' --model='<model_name>'
```
没有合适的资源?快使用搜索试试~ 我知道了~
torchvision 0.9.0
共542个文件
py:173个
cpp:64个
pkl:50个
需积分: 9 5 下载量 90 浏览量
2022-09-14
11:05:31
上传
评论
收藏 7.13MB ZIP 举报
温馨提示
torchvision 0.9.0
资源详情
资源评论
资源推荐
收起资源包目录
torchvision 0.9.0 (542个子文件)
v_SoccerJuggling_g24_c01.avi 608KB
v_SoccerJuggling_g23_c01.avi 496KB
hmdb51_Turnk_r_Pippi_Michel_cartwheel_f_cm_np2_le_med_6.avi 350KB
SchoolRulesHowTheyHelpUs_wave_f_nm_np1_ba_med_0.avi 283KB
RATRACE_wave_f_nm_np1_fr_goo_37.avi 258KB
TrumanShow_wave_f_nm_np1_fr_med_26.avi 237KB
pkg_helpers.bash 16KB
cuda_install.bat 10KB
nightly_defaults.bat 8KB
build_vision.bat 5KB
upload.bat 2KB
clone.bat 2KB
test.bat 2KB
check_deps.bat 2KB
install_runtime.bat 2KB
install_runtime.bat 2KB
install_activate.bat 2KB
install_activate.bat 2KB
publish.bat 2KB
cuda102.bat 1KB
cuda101.bat 1KB
cuda100.bat 1KB
cuda92.bat 1KB
cuda90.bat 1KB
activate.bat 1KB
activate.bat 1KB
auth.bat 1KB
vc_env_helper.bat 972B
env_fix.bat 931B
setup.bat 925B
vc_env_helper.bat 887B
copy.bat 799B
make.bat 783B
check_opts.bat 652B
cpu.bat 621B
build_conda.bat 605B
vs_install.bat 577B
build_wheels.bat 469B
dep_install.bat 332B
build_cmake.bat 309B
build_frcnn.bat 222B
build_cpp_example.bat 215B
install_conda.bat 107B
install_conda.bat 106B
copy_cpu.bat 58B
clean.bat 56B
setup.cfg 254B
.clang-format 3KB
.coveragerc 89B
deform_conv2d_kernel.cpp 33KB
video_reader.cpp 21KB
decoder.cpp 18KB
roi_align_kernel.cpp 14KB
inception.cpp 13KB
ps_roi_align_kernel.cpp 13KB
sync_decoder_test.cpp 12KB
util.cpp 12KB
video.cpp 10KB
ps_roi_pool_kernel.cpp 9KB
roi_pool_kernel.cpp 8KB
test_models.cpp 7KB
video_sampler.cpp 7KB
stream.cpp 7KB
googlenet.cpp 7KB
deform_conv2d_kernel.cpp 7KB
densenet.cpp 6KB
mnasnet.cpp 6KB
audio_sampler.cpp 6KB
shufflenetv2.cpp 5KB
decode_png.cpp 5KB
decode_jpeg.cpp 5KB
mobilenet.cpp 5KB
encode_png.cpp 5KB
ps_roi_align_kernel.cpp 5KB
roi_align_kernel.cpp 4KB
resnet.cpp 4KB
ps_roi_pool_kernel.cpp 4KB
roi_pool_kernel.cpp 4KB
vgg.cpp 4KB
video_stream.cpp 4KB
squeezenet.cpp 4KB
seekable_buffer.cpp 3KB
nms_kernel.cpp 3KB
encode_jpeg.cpp 3KB
read_write_file.cpp 3KB
audio_stream.cpp 3KB
deform_conv2d.cpp 2KB
roi_align.cpp 2KB
sync_decoder.cpp 2KB
subtitle_stream.cpp 2KB
test_custom_operators.cpp 2KB
ps_roi_align.cpp 2KB
ps_roi_pool.cpp 2KB
roi_pool.cpp 2KB
alexnet.cpp 2KB
memory_buffer.cpp 2KB
test_frcnn_tracing.cpp 2KB
deform_conv2d_kernel.cpp 1KB
util_test.cpp 1KB
decode_image.cpp 1018B
共 542 条
- 1
- 2
- 3
- 4
- 5
- 6
阿小良
- 粉丝: 0
- 资源: 4
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- 成都市地图含高新区(高新南区,高新西区),天府新区,东部新区虚拟行政区划
- XILINXFPGA源码XilinxEDK设计试验
- XILINXFPGA源码XilinxEDKMicroBlaze内置USB固件程序
- 基于 django 的视频点播后台管理系统源代码+数据库
- 基于Java的网上医院预约挂号系统的设计与实现(部署视频)-kaic.mp4
- 新建项目opengrok
- XILINXFPGA源码XilinxDDR3最新VHDL代码(通过调试)
- XILINXFPGA源码XilinxDDR2存储器接口调试代码
- 班级事务管理系统设计与实现(部署视频)-kaic.mp4
- excel带下拉框展示(动态展示)
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
评论0