提交 d183ca55 编写于 作者: Y Yancey1989

update by comment

上级 2fa0c3dc
# PaddlePaddle Fast ResNet
# PaddlePaddle Fast ImageNet Training
PaddlePaddle Fast ResNet can train ImageNet with fewer epochs. We implemented the it according to the blog
PaddlePaddle Fast ImageNet can train ImageNet dataset with fewer epochs. We implemented the it according to the blog
[Now anyone can train Imagenet in 18 minutes](https://www.fast.ai/2018/08/10/fastai-diu-imagenet/) which published on the [fast.ai] website.
PaddlePaddle Fast ResNet using the dynmiac batch size, dynamic image size, rectangular images validation and etc... so that the FastResNet can achieve the baseline
(acc1: 75%, acc5: 93%) by 27 epochs on 8 GPUs.
PaddlePaddle Fast ImageNet using the dynmiac batch size, dynamic image size, rectangular images validation and etc... so that the Fast ImageNet can achieve the baseline
(acc1: 75%, acc5: 93%) by 27 epochs on 8 * V100 GPUs.
## Experiment
1. Preparing the training data, resize the images to 160 and 352 by `resize.py`, the prepared data folder is as followed:
1. Prepare the training data, resize the images to 160 and 352 using `resize.py`, the prepared data folder should look like:
``` text
`-ImageNet
|-train
......
......@@ -14,8 +14,7 @@ def mkdir(path):
path.mkdir()
mkdir(DEST)
#szs = (160, 352)
szs = (160,)
szs = (160, 352)
def resize_img(p, im, fn, sz):
w,h = im.size
......@@ -40,8 +39,6 @@ for sz in szs:
for ds in ('validation','train'): mkdir((DEST/ssz/ds))
for ds in ('train',): mkdir((DEST/ssz/ds))
#for ds in ('val','train'): resize_imgs(PATH/ds)
#for ds in ("validation", "train"):
for ds in ("validation", ):
for ds in ("validation", "train"):
print(PATH/ds)
resize_imgs(PATH/ds)
\ No newline at end of file
......@@ -31,7 +31,7 @@ import sys
sys.path.append("..")
from utility import add_arguments, print_arguments
import functools
from models.fast_resnet import FastResNet, lr_decay
from models.fast_imagenet import FastImageNet, lr_decay
import utils
def parse_args():
......@@ -46,7 +46,6 @@ def parse_args():
add_arg('checkpoint', str, None, "Whether to resume checkpoint.")
add_arg('lr', float, 1.0, "set learning rate.")
add_arg('lr_strategy', str, "piecewise_decay", "Set the learning rate decay strategy.")
add_arg('model', str, "FastResNet", "Set the network to use.")
add_arg('data_dir', str, "./data/ILSVRC2012", "The ImageNet dataset root dir.")
add_arg('model_category', str, "models", "Whether to use models_name or not, valid value:'models','models_name'" )
add_arg('fp16', bool, False, "Enable half precision training with fp16." )
......@@ -123,7 +122,7 @@ def build_program(args, is_train, main_prog, startup_prog, py_reader_startup_pro
t1 = fluid.layers.elementwise_sub(cast, img_mean, axis=1)
t2 = fluid.layers.elementwise_div(t1, img_std, axis=1)
model = FastResNet(is_train=is_train)
model = FastImageNet(is_train=is_train)
predict = model.net(t2, class_dim=class_dim, img_size=sz)
cost, pred = fluid.layers.softmax_with_cross_entropy(predict, label, return_softmax=True)
if args.scale_loss > 1:
......
......@@ -9,4 +9,4 @@ from .inception_v4 import InceptionV4
from .se_resnext import SE_ResNeXt50_32x4d, SE_ResNeXt101_32x4d, SE_ResNeXt152_32x4d
from .dpn import DPN68, DPN92, DPN98, DPN107, DPN131
from .shufflenet_v2 import ShuffleNetV2_x0_5, ShuffleNetV2_x1_0, ShuffleNetV2_x1_5, ShuffleNetV2_x2_0
from .fast_resnet import FastResNet
from .fast_imagenet import FastImageNet
......@@ -30,9 +30,9 @@ import paddle.fluid.core as core
import paddle.fluid.profiler as profiler
import utils
__all__ = ["FastResNet"]
__all__ = ["FastImageNet"]
class FastResNet():
class FastImageNet():
def __init__(self, layers=50, is_train=True):
self.layers = layers
self.is_train = is_train
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册