From 81706e21adad14993b5456ee5fb4ef2f7b949bef Mon Sep 17 00:00:00 2001 From: jiangzhenguang Date: Mon, 1 Mar 2021 19:03:54 +0800 Subject: [PATCH] remove the reduce fusion config of resnet18. --- model_zoo/official/cv/resnet/README.md | 8 ++++---- model_zoo/official/cv/resnet/README_CN.md | 8 ++++---- model_zoo/official/cv/resnet/src/resnet.py | 21 ++++++++++++--------- model_zoo/official/cv/resnet/train.py | 4 +--- 4 files changed, 21 insertions(+), 20 deletions(-) diff --git a/model_zoo/official/cv/resnet/README.md b/model_zoo/official/cv/resnet/README.md index 94b54063a67..e71a6022182 100644 --- a/model_zoo/official/cv/resnet/README.md +++ b/model_zoo/official/cv/resnet/README.md @@ -492,8 +492,8 @@ result: {'top_5_accuracy': 0.9342589628681178, 'top_1_accuracy': 0.7680657810499 | Loss Function | Softmax Cross Entropy | | outputs | probability | | Loss | 0.0002519517 | -| Speed | 10 ms/step(8pcs) | -| Total time | 3 mins | +| Speed | 13 ms/step(8pcs) | +| Total time | 4 mins | | Parameters (M) | 11.2 | | Checkpoint for Fine tuning | 86M (.ckpt file) | | Scripts | [Link](https://gitee.com/mindspore/mindspore/tree/master/model_zoo/official/cv/resnet) | @@ -512,8 +512,8 @@ result: {'top_5_accuracy': 0.9342589628681178, 'top_1_accuracy': 0.7680657810499 | Loss Function | Softmax Cross Entropy | | outputs | probability | | Loss | 2.15702 | -| Speed | 140ms/step(8pcs) | -| Total time | 131 mins | +| Speed | 110ms/step(8pcs) (may need to set_numa_enbale in dataset.py) | +| Total time | 110 mins | | Parameters (M) | 11.7 | | Checkpoint for Fine tuning | 90M (.ckpt file) | | Scripts | [Link](https://gitee.com/mindspore/mindspore/tree/master/model_zoo/official/cv/resnet) | diff --git a/model_zoo/official/cv/resnet/README_CN.md b/model_zoo/official/cv/resnet/README_CN.md index 04b9b7efa15..0d6204d90bf 100755 --- a/model_zoo/official/cv/resnet/README_CN.md +++ b/model_zoo/official/cv/resnet/README_CN.md @@ -459,8 +459,8 @@ result:{'top_5_accuracy':0.9342589628681178, 'top_1_accuracy':0.768065781049936} | 损失函数 | Softmax交叉熵 | | 输出 | 概率 | | 损失 | 0.0002519517 | -| 速度 | 10毫秒/步(8卡) | -| 总时长 | 3分钟 | +| 速度 | 13毫秒/步(8卡) | +| 总时长 | 4分钟 | | 参数(M) | 11.2 | | 微调检查点 | 86(.ckpt文件) | | 脚本 | [链接](https://gitee.com/mindspore/mindspore/tree/master/model_zoo/official/cv/resnet) | @@ -479,8 +479,8 @@ result:{'top_5_accuracy':0.9342589628681178, 'top_1_accuracy':0.768065781049936} | 损失函数 | Softmax交叉熵 | | 输出 | 概率 | | 损失 | 2.15702 | -| 速度 | 140毫秒/步(8卡) | -| 总时长 | 131分钟 | +| 速度 | 110毫秒/步(8卡) (可能需要在datasetpy中增加set_numa_enbale绑核操作) | +| 总时长 | 110分钟 | | 参数(M) | 11.7 | | 微调检查点| 90M(.ckpt文件) | | 脚本 | [链接](https://gitee.com/mindspore/mindspore/tree/master/model_zoo/official/cv/resnet) | diff --git a/model_zoo/official/cv/resnet/src/resnet.py b/model_zoo/official/cv/resnet/src/resnet.py index b18e3279182..507a18c4a06 100755 --- a/model_zoo/official/cv/resnet/src/resnet.py +++ b/model_zoo/official/cv/resnet/src/resnet.py @@ -176,8 +176,8 @@ class ResidualBlock(nn.Cell): in_channel (int): Input channel. out_channel (int): Output channel. stride (int): Stride size for the first convolutional layer. Default: 1. - use_se (bool): enable SE-ResNet50 net. Default: False. - se_block(bool): use se block in SE-ResNet50 net. Default: False. + use_se (bool): Enable SE-ResNet50 net. Default: False. + se_block(bool): Use se block in SE-ResNet50 net. Default: False. Returns: Tensor, output tensor. @@ -276,8 +276,9 @@ class ResidualBlockBase(nn.Cell): in_channel (int): Input channel. out_channel (int): Output channel. stride (int): Stride size for the first convolutional layer. Default: 1. - use_se (bool): enable SE-ResNet50 net. Default: False. - se_block(bool): use se block in SE-ResNet50 net. Default: False. + use_se (bool): Enable SE-ResNet50 net. Default: False. + se_block(bool): Use se block in SE-ResNet50 net. Default: False. + res_base (bool): Enable parameter setting of resnet18. Default: True. Returns: Tensor, output tensor. @@ -290,9 +291,9 @@ class ResidualBlockBase(nn.Cell): in_channel, out_channel, stride=1, - res_base=True, use_se=False, - se_block=False): + se_block=False, + res_base=True): super(ResidualBlockBase, self).__init__() self.res_base = res_base self.conv1 = _conv3x3(in_channel, out_channel, stride=stride, res_base=self.res_base) @@ -341,8 +342,10 @@ class ResNet(nn.Cell): out_channels (list): Output channel in each layer. strides (list): Stride size in each layer. num_classes (int): The number of classes that the training images are belonging to. - use_se (bool): enable SE-ResNet50 net. Default: False. - se_block(bool): use se block in SE-ResNet50 net in layer 3 and layer 4. Default: False. + use_se (bool): Enable SE-ResNet50 net. Default: False. + se_block(bool): Use se block in SE-ResNet50 net in layer 3 and layer 4. Default: False. + res_base (bool): Enable parameter setting of resnet18. Default: True. + Returns: Tensor, output tensor. @@ -432,7 +435,7 @@ class ResNet(nn.Cell): in_channel (int): Input channel. out_channel (int): Output channel. stride (int): Stride size for the first convolutional layer. - se_block(bool): use se block in SE-ResNet50 net. Default: False. + se_block(bool): Use se block in SE-ResNet50 net. Default: False. Returns: SequentialCell, the output layer. diff --git a/model_zoo/official/cv/resnet/train.py b/model_zoo/official/cv/resnet/train.py index e04c5222f2d..a434c2c21fd 100755 --- a/model_zoo/official/cv/resnet/train.py +++ b/model_zoo/official/cv/resnet/train.py @@ -110,9 +110,7 @@ if __name__ == '__main__': set_algo_parameters(elementwise_op_strategy_follow=True) if args_opt.net == "resnet50" or args_opt.net == "se-resnet50": context.set_auto_parallel_context(all_reduce_fusion_config=[85, 160]) - elif args_opt.net == "resnet18": - context.set_auto_parallel_context(all_reduce_fusion_config=[40, 61]) - else: + elif args_opt.net == "resnet101": context.set_auto_parallel_context(all_reduce_fusion_config=[180, 313]) init() # GPU target