ResNet_wide for CIFAR10

P粉084495128
发布: 2025-07-28 13:25:09
原创
824人浏览过
本项目基于PaddlePaddle复现Wide Resnet,它是ResNet变体,改进了shortcut,采用更宽卷积并加dropout层。在CIFAR10测试集精度达96.6%,提供单卡和多卡训练方式,代码含模型、训练、评估等文件,依赖PaddlePaddle≥2.0.0,支持GPU和CPU运行。

☞☞☞AI 智能聊天, 问答助手, AI 智能搜索, 免费无限量使用 DeepSeek R1 模型☜☜☜

resnet_wide for cifar10 - php中文网

一、简介

本项目基于paddlepaddle框架复现Wide Resnet,他是resnet的一种变体,主要区别在于对resnet的shortcut进行了改进,使用更“宽”的卷积以及加上了dropout层。

论文:

  • [1] Zagoruyko S , Komodakis N . Wide Residual Networks[J]. 2016.
  • 链接:Wide Residual Networks

参考项目:

  • https://github.com/xternalz/WideResNet-pytorch
  • https://github.com/meliketoy/wide-resnet.pytorch/blob/master/networks/wide_resnet.py

二、复现精度

该列指标在cifar10的测试集测试

train from scratch细节:


epoch opt batch_size dataset memory card precision
1 400 SGD 128 CIFAR10 16G 1 0.9660

模型下载 模型地址:aistudio

三、数据集

CIFAR10数据集。

  • 数据集大小:
    • 训练集:50000张
    • 测试集:10000张
    • 尺寸:32 * 32
  • 数据格式:分类数据集

四、环境依赖

  • 硬件:GPU、CPU

  • 框架:

    • PaddlePaddle >= 2.0.0

五、快速开始

step1: clone

# clone this repogit clone https://github.com/PaddlePaddle/Contrib.gitcd wide_resnetexport PYTHONPATH=./
登录后复制

安装依赖

PHP 5 _ MySQLProgramming for the Absolute Beginner
PHP 5 _ MySQLProgramming for the Absolute Beginner

PHP 5 _ MySQL Programming for the Absolute Beginner

PHP 5 _ MySQLProgramming for the Absolute Beginner 349
查看详情 PHP 5 _ MySQLProgramming for the Absolute Beginner
python3 -m pip install -r requirements.txt
登录后复制

step2: 训练

python3 train.py
登录后复制

如果你想分布式训练并使用多卡:

python3 -m paddle.distributed.launch --log_dir=./debug/ --gpus '0,1,2,3' train.py
登录后复制

此时的输出为:

Epoch 0: PiecewiseDecay set learning rate to 0.05.iter:0  loss:2.4832iter:10  loss:2.3544iter:20  loss:2.3087iter:30  loss:2.2509iter:40  loss:2.2450
登录后复制

step3: 测试

python3 eval.py
登录后复制

此时的输出为:

acc:9660 total:10000 ratio:0.966
登录后复制

六、代码结构与详细说明

6.1 代码结构

│  wide_resnet.py                 # 模型文件│  eval.py                        # 评估│  README.md                      # 英文readme│  README_cn.md                   # 中文readme│  requirement.txt                # 依赖│  train.py                       # 训练
登录后复制

6.2 参数说明

6.3 训练流程

单机训练

python3 train.py
登录后复制

多机训练

python3 -m paddle.distributed.launch --log_dir=./debug/ --gpus '0,1,2,3' train.py
登录后复制

此时,程序会将每个进程的输出log导入到./debug路径下:

.
├── debug
│   ├── workerlog.0│   ├── workerlog.1│   ├── workerlog.2│   └── workerlog.3├── README.md
└── train.py
登录后复制

训练输出

执行训练开始后,将得到类似如下的输出。每一轮batch训练将会打印当前epoch、step以及loss值。

Epoch 0: PiecewiseDecay set learning rate to 0.05.
iter:0  loss:2.4832
iter:10  loss:2.3544
iter:20  loss:2.3087
iter:30  loss:2.2509
iter:40  loss:2.2450
登录后复制

6.4 评估流程

python3 eval.py
登录后复制

此时的输出为:

acc:9660 total:10000 ratio:0.966
登录后复制

七、模型信息

关于模型的其他信息,可以参考下表:

信息 说明
发布者 徐铭远
时间 2021.08
框架版本 >=Paddle 2.0.2
应用场景 图像分类
支持硬件 GPU、CPU
下载链接 预训练模型
In [ ]
# 以下为在aistudio上直接运行
登录后复制
In [4]
# 训练!python3 train.py
登录后复制
/opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages/paddle/fluid/layers/utils.py:26: DeprecationWarning: `np.int` is a deprecated alias for the builtin `int`. To silence this warning, use `int` by itself. Doing this will not modify any behavior and is safe. When replacing `np.int`, you may wish to use e.g. `np.int64` or `np.int32` to specify the precision. If you wish to review your current use, check the release note link for additional information.
Deprecated in NumPy 1.20; for more details and guidance: https://numpy.org/devdocs/release/1.20.0-notes.html#deprecations
  def convert_to_list(value, n, name, dtype=np.int):
W0808 16:41:54.148313 32483 device_context.cc:362] Please NOTE: device: 0, GPU Compute Capability: 7.0, Driver API Version: 10.1, Runtime API Version: 10.1
W0808 16:41:54.152312 32483 device_context.cc:372] device: 0, cuDNN Version: 7.6.
Epoch 0: PiecewiseDecay set learning rate to 0.05.
iter:0  loss:2.4279
iter:10  loss:2.3434
^C
登录后复制
In [ ]
# 评估!python3 eval.py
登录后复制
/opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages/paddle/fluid/layers/utils.py:26: DeprecationWarning: `np.int` is a deprecated alias for the builtin `int`. To silence this warning, use `int` by itself. Doing this will not modify any behavior and is safe. When replacing `np.int`, you may wish to use e.g. `np.int64` or `np.int32` to specify the precision. If you wish to review your current use, check the release note link for additional information.
Deprecated in NumPy 1.20; for more details and guidance: https://numpy.org/devdocs/release/1.20.0-notes.html#deprecations
  def convert_to_list(value, n, name, dtype=np.int):
W0808 16:37:21.490298 32096 device_context.cc:362] Please NOTE: device: 0, GPU Compute Capability: 7.0, Driver API Version: 10.1, Runtime API Version: 10.1
W0808 16:37:21.494925 32096 device_context.cc:372] device: 0, cuDNN Version: 7.6.
acc:9660 total:10000 ratio:0.966
登录后复制

以上就是ResNet_wide for CIFAR10的详细内容,更多请关注php中文网其它相关文章!

最佳 Windows 性能的顶级免费优化软件
最佳 Windows 性能的顶级免费优化软件

每个人都需要一台速度更快、更稳定的 PC。随着时间的推移,垃圾文件、旧注册表数据和不必要的后台进程会占用资源并降低性能。幸运的是,许多工具可以让 Windows 保持平稳运行。

下载
来源:php中文网
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn
最新问题
开源免费商场系统广告
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
关于我们 免责申明 意见反馈 讲师合作 广告合作 最新更新 English
php中文网:公益在线php培训,帮助PHP学习者快速成长!
关注服务号 技术交流群
PHP中文网订阅号
每天精选资源文章推送
PHP中文网APP
随时随地碎片化学习

Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号