未验证 提交 503ebb48 编写于 作者: R ruri 提交者: GitHub

fix py3 bugs (#2437)

上级 dc8813aa
......@@ -167,13 +167,13 @@ Available top-1/top-5 validation accuracy on ImageNet 2012 are listed in table.
|[ResNet101_vd](https://paddle-imagenet-models-name.bj.bcebos.com/ResNet101_vd_pretrained.tar) | 79.44%/94.47% |
|[ResNet152](https://paddle-imagenet-models-name.bj.bcebos.com/ResNet152_pretrained.tar) | 78.26%/93.96% |
|[ResNet152_vd](https://paddle-imagenet-models-name.bj.bcebos.com/ResNet152_vd_pretrained.tar) | 80.59%/95.30% |
|[ResNet200_vd](https://paddle-imagenet-models-name.bj.bcebos.com/ResNet152_vd_pretrained.tar) | 80.93%/95.33% |
|[ResNet200_vd](https://paddle-imagenet-models-name.bj.bcebos.com/ResNet200_vd_pretrained.tar) | 80.93%/95.33% |
|[ResNeXt101_64x4d](https://paddle-imagenet-models-name.bj.bcebos.com/ResNeXt101_64x4d_pretrained.tar) | 79.35%/94.52% |
|[ResNeXt101_vd_64x4d](https://paddle-imagenet-models-name.bj.bcebos.com/ResNeXt101_vd_64x4d_pretrained.tar) | 80.78%/95.20% |
|[SE_ResNeXt50_32x4d](https://paddle-imagenet-models-name.bj.bcebos.com/SE_ResNeXt50_32x4d_pretrained.tar) | 78.44%/93.96% |
|[SE_ResNeXt101_32x4d](https://paddle-imagenet-models-name.bj.bcebos.com/SE_ResNeXt101_32x4d_pretrained.tar) | 79.12%/94.20% |
|[SE154_vd](https://paddle-imagenet-models-name.bj.bcebos.com/SE154_vd_pretrained.tar) | 81.45%/95.49% |
|[SE154_vd](https://paddle-imagenet-models-name.bj.bcebos.com/SE154_vd_pretrained.tar) | 81.40%/95.48% |
|[GoogleNet](https://paddle-imagenet-models-name.bj.bcebos.com/GoogleNet_pretrained.tar) | 70.70%/89.66% |
|[ShuffleNetV2](https://paddle-imagenet-models-name.bj.bcebos.com/ShuffleNetV2_pretrained.tar) | 70.03%/89.17% |
|[InceptionV4](https://paddle-imagenet-models-name.bj.bcebos.com/InceptionV4_pretrained.tar) | 80.88%/95.28% |
|[InceptionV4](https://paddle-imagenet-models-name.bj.bcebos.com/InceptionV4_pretrained.tar) | 80.77%/95.26% |
......@@ -163,12 +163,12 @@ python infer.py \
|[ResNet101_vd](https://paddle-imagenet-models-name.bj.bcebos.com/ResNet101_vd_pretrained.tar) | 79.44%/94.47% |
|[ResNet152](https://paddle-imagenet-models-name.bj.bcebos.com/ResNet152_pretrained.tar) | 78.26%/93.96% |
|[ResNet152_vd](https://paddle-imagenet-models-name.bj.bcebos.com/ResNet152_vd_pretrained.tar) | 80.59%/95.30% |
|[ResNet200_vd](https://paddle-imagenet-models-name.bj.bcebos.com/ResNet152_vd_pretrained.tar) | 80.93%/95.33% |
|[ResNet200_vd](https://paddle-imagenet-models-name.bj.bcebos.com/ResNet200_vd_pretrained.tar) | 80.93%/95.33% |
|[ResNeXt101_64x4d](https://paddle-imagenet-models-name.bj.bcebos.com/ResNeXt101_64x4d_pretrained.tar) | 79.35%/94.52% |
|[ResNeXt101_vd_64x4d](https://paddle-imagenet-models-name.bj.bcebos.com/ResNeXt101_vd_64x4d_pretrained.tar) | 80.78%/95.20% |
|[SE_ResNeXt50_32x4d](https://paddle-imagenet-models-name.bj.bcebos.com/SE_ResNeXt50_32x4d_pretrained.tar) | 78.44%/93.96% |
|[SE_ResNeXt101_32x4d](https://paddle-imagenet-models-name.bj.bcebos.com/SE_ResNeXt101_32x4d_pretrained.tar) | 79.12%/94.20% |
|[SE154_vd](https://paddle-imagenet-models-name.bj.bcebos.com/SE154_vd_pretrained.tar) | 81.45%/95.49% |
|[SE154_vd](https://paddle-imagenet-models-name.bj.bcebos.com/SE154_vd_pretrained.tar) | 81.40%/95.48% |
|[GoogleNet](https://paddle-imagenet-models-name.bj.bcebos.com/GoogleNet_pretrained.tar) | 70.70%/89.66% |
|[ShuffleNetV2](https://paddle-imagenet-models-name.bj.bcebos.com/ShuffleNetV2_pretrained.tar) | 70.03%/89.17% |
|[InceptionV4](https://paddle-imagenet-models-name.bj.bcebos.com/InceptionV4_pretrained.tar) | 80.88%/95.28% |
|[InceptionV4](https://paddle-imagenet-models-name.bj.bcebos.com/InceptionV4_pretrained.tar) | 80.77%/95.26% |
......@@ -77,12 +77,8 @@ def eval(args):
exe = fluid.Executor(place)
exe.run(fluid.default_startup_program())
if pretrained_model:
def if_exist(var):
return os.path.exists(os.path.join(pretrained_model, var.name))
fluid.io.load_vars(exe, pretrained_model, predicate=if_exist)
fluid.io.load_persistables(exe, pretrained_model)
val_reader = paddle.batch(reader.val(settings=args), batch_size=args.batch_size)
feeder = fluid.DataFeeder(place=place, feed_list=[image, label])
......
......@@ -61,12 +61,7 @@ def infer(args):
exe = fluid.Executor(place)
exe.run(fluid.default_startup_program())
if pretrained_model:
def if_exist(var):
return os.path.exists(os.path.join(pretrained_model, var.name))
fluid.io.load_vars(exe, pretrained_model, predicate=if_exist)
fluid.io.load_persistables(exe, pretrained_model)
if save_inference:
fluid.io.save_inference_model(
dirname=model_name,
......
......@@ -147,7 +147,7 @@ class SE_ResNeXt():
act='relu',
name='conv'+name+'_x2')
if cardinality == 64:
num_filters = num_filters / 2
num_filters = num_filters // 2
conv2 = self.conv_bn_layer(
input=conv1, num_filters=num_filters * 2, filter_size=1, act=None, name='conv'+name+'_x3')
scale = self.squeeze_excitation(
......@@ -224,7 +224,7 @@ class SE_ResNeXt():
input=input, pool_size=0, pool_type='avg', global_pooling=True)
stdv = 1.0 / math.sqrt(pool.shape[1] * 1.0)
squeeze = fluid.layers.fc(input=pool,
size=num_channels / reduction_ratio,
size=num_channels // reduction_ratio,
act='relu',
param_attr=fluid.param_attr.ParamAttr(
initializer=fluid.initializer.Uniform(
......
......@@ -81,8 +81,8 @@ def crop_image(img, target_size, center):
height, width = img.shape[:2]
size = target_size
if center == True:
w_start = (width - size) / 2
h_start = (height - size) / 2
w_start = (width - size) // 2
h_start = (height - size) // 2
else:
w_start = np.random.randint(0, width - size + 1)
h_start = np.random.randint(0, height - size + 1)
......
......@@ -15,143 +15,141 @@ python train.py \
# >log_SE_ResNeXt50_32x4d.txt 2>&1 &
#SE_154
"""
python train.py \
--model=SE_154_vd \
--batch_size=256 \
--total_images=1281167 \
--image_shape=3,224,224 \
--input_dtype=float32 \
--class_dim=1000 \
--lr_strategy=cosine_decay \
--lr=0.1 \
--num_epochs=200 \
--with_mem_opt=True \
--model_save_dir=output/ \
--l2_decay=1e-4 \
--use_mixup=True \
--use_label_smoothing=True \
--label_smoothing_epsilon=0.1 \
#python train.py \
# --model=SE_154_vd \
# --batch_size=256 \
# --total_images=1281167 \
# --image_shape=3,224,224 \
# --input_dtype=float32 \
# --class_dim=1000 \
# --lr_strategy=cosine_decay \
# --lr=0.1 \
# --num_epochs=200 \
# --with_mem_opt=True \
# --model_save_dir=output/ \
# --l2_decay=1e-4 \
# --use_mixup=True \
# --use_label_smoothing=True \
# --label_smoothing_epsilon=0.1 \
#ResNeXt101_64x4d
python train.py \
--model=ResNeXt101_64x4d \
--batch_size=256 \
--total_images=1281167 \
--image_shape=3,224,224 \
--input_dtype=float32 \
--class_dim=1000 \
--lr_strategy=piecewise_decay \
--lr=0.1 \
--num_epochs=120 \
--with_mem_opt=True \
--model_save_dir=output/ \
--l2_decay=15e-5
#python train.py \
# --model=ResNeXt101_64x4d \
# --batch_size=256 \
# --total_images=1281167 \
# --image_shape=3,224,224 \
# --input_dtype=float32 \
# --class_dim=1000 \
# --lr_strategy=piecewise_decay \
# --lr=0.1 \
# --num_epochs=120 \
# --with_mem_opt=True \
# --model_save_dir=output/ \
# --l2_decay=15e-5
python train.py \
#python train.py \
#ResNeXt101_vd_64x4d
--model=ResNeXt101_vd_64x4d \
--batch_size=256 \
--total_images=1281167 \
--image_shape=3,224,224 \
--input_dtype=float32 \
--class_dim=1000 \
--lr_strategy=cosine_decay \
--lr=0.1 \
--num_epochs=200 \
--with_mem_opt=True \
--model_save_dir=output/ \
--l2_decay=1e-4 \
--use_mixup=True \
--use_label_smoothing=True \
--label_smoothing_epsilon=0.1
# --model=ResNeXt101_vd_64x4d \
# --batch_size=256 \
# --total_images=1281167 \
# --image_shape=3,224,224 \
# --input_dtype=float32 \
# --class_dim=1000 \
# --lr_strategy=cosine_decay \
# --lr=0.1 \
# --num_epochs=200 \
# --with_mem_opt=True \
# --model_save_dir=output/ \
# --l2_decay=1e-4 \
# --use_mixup=True \
# --use_label_smoothing=True \
# --label_smoothing_epsilon=0.1
#InceptionV4
python train.py
--model=InceptionV4 \
--batch_size=256 \
--total_images=1281167 \
--image_shape=3,299,299 \
--input_dtype=float32 \
--class_dim=1000 \
--lr_strategy=cosine_decay \
--lr=0.045 \
--num_epochs=200 \
--with_mem_opt=True \
--model_save_dir=output/ \
--l2_decay=1e-4 \
--use_mixup=True \
--resize_short_size=320 \
--use_label_smoothing=True \
--label_smoothing_epsilon=0.1 \
#python train.py
# --model=InceptionV4 \
# --batch_size=256 \
# --total_images=1281167 \
# --image_shape=3,299,299 \
# --input_dtype=float32 \
# --class_dim=1000 \
# --lr_strategy=cosine_decay \
# --lr=0.045 \
# --num_epochs=200 \
# --with_mem_opt=True \
# --model_save_dir=output/ \
# --l2_decay=1e-4 \
# --use_mixup=True \
# --resize_short_size=320 \
# --use_label_smoothing=True \
# --label_smoothing_epsilon=0.1 \
#ResNet152_vd
python train.py
--model=ResNet152_vd \
--batch_size=256 \
--total_images=1281167 \
--image_shape=3,224,224 \
--input_dtype=float32 \
--class_dim=1000 \
--lr_strategy=cosine_decay \
--lr=0.1 \
--num_epochs=200 \
--with_mem_opt=True \
--model_save_dir=output/ \
--l2_decay=1e-4 \
--use_mixup=True \
--use_label_smoothing=True \
--label_smoothing_epsilon=0.1
#python train.py
# --model=ResNet152_vd \
# --batch_size=256 \
# --total_images=1281167 \
# --image_shape=3,224,224 \
# --input_dtype=float32 \
# --class_dim=1000 \
# --lr_strategy=cosine_decay \
# --lr=0.1 \
# --num_epochs=200 \
# --with_mem_opt=True \
# --model_save_dir=output/ \
# --l2_decay=1e-4 \
# --use_mixup=True \
# --use_label_smoothing=True \
# --label_smoothing_epsilon=0.1
#ResNet200_vd
python train.py
--model=ResNet200_vd \
--batch_size=256 \
--total_images=1281167 \
--image_shape=3,224,224 \
--input_dtype=float32 \
--class_dim=1000 \
--lr_strategy=cosine_decay \
--lr=0.1 \
--num_epochs=200 \
--with_mem_opt=True \
--model_save_dir=output/ \
--l2_decay=1e-4 \
--use_mixup=True \
--use_label_smoothing=True \
--label_smoothing_epsilon=0.1
#python train.py
# --model=ResNet200_vd \
# --batch_size=256 \
# --total_images=1281167 \
# --image_shape=3,224,224 \
# --input_dtype=float32 \
# --class_dim=1000 \
# --lr_strategy=cosine_decay \
# --lr=0.1 \
# --num_epochs=200 \
# --with_mem_opt=True \
# --model_save_dir=output/ \
# --l2_decay=1e-4 \
# --use_mixup=True \
# --use_label_smoothing=True \
# --label_smoothing_epsilon=0.1
#ResNet50_vd
python train.py
--model=ResNet50_vd \
--batch_size=256 \
--total_images=1281167 \
--image_shape=3,224,224 \
--input_dtype=float32 \
--class_dim=1000 \
--lr_strategy=cosine_decay \
--lr=0.1 \
--num_epochs=200 \
--with_mem_opt=True \
--model_save_dir=output/ \
--l2_decay=7e-5 \
--use_mixup=True \
--use_label_smoothing=True \
--label_smoothing_epsilon=0.1
#python train.py
# --model=ResNet50_vd \
# --batch_size=256 \
# --total_images=1281167 \
# --image_shape=3,224,224 \
# --input_dtype=float32 \
# --class_dim=1000 \
# --lr_strategy=cosine_decay \
# --lr=0.1 \
# --num_epochs=200 \
# --with_mem_opt=True \
# --model_save_dir=output/ \
# --l2_decay=7e-5 \
# --use_mixup=True \
# --use_label_smoothing=True \
# --label_smoothing_epsilon=0.1
#ResNet50_vc
python train.py
--model=ResNet50_vc \
--batch_size=256 \
--total_images=1281167 \
--image_shape=3,224,224 \
--input_dtype=float32 \
--class_dim=1000 \
--lr_strategy=cosine_decay \
--lr=0.1 \
--num_epochs=200 \
--with_mem_opt=True \
--model_save_dir=output/ \
--l2_decay=1e-4 \
"""
#python train.py
# --model=ResNet50_vc \
# --batch_size=256 \
# --total_images=1281167 \
# --image_shape=3,224,224 \
# --input_dtype=float32 \
# --class_dim=1000 \
# --lr_strategy=cosine_decay \
# --lr=0.1 \
# --num_epochs=200 \
# --with_mem_opt=True \
# --model_save_dir=output/ \
# --l2_decay=1e-4 \
#AlexNet:
#python train.py \
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册