Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit dda23ec

Browse files
authored
Merge pull request tensorflow#5223 from tfboyd/update_resnet_defaults_v1
Update resnet defaults v1
2 parents 481728d + 76c0ac5 commit dda23ec

File tree

3 files changed

+20
-4
lines changed

3 files changed

+20
-4
lines changed

official/resnet/README.md

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,23 @@ See the following papers for more background:
88

99
[2] [Identity Mappings in Deep Residual Networks](https://arxiv.org/pdf/1603.05027.pdf) by Kaiming He, Xiangyu Zhang, Shaoqing Ren, and Jian Sun, Jul 2016.
1010

11-
In code v1 refers to the resnet defined in [1], while v2 correspondingly refers to [2]. The principle difference between the two versions is that v1 applies batch normalization and activation after convolution, while v2 applies batch normalization, then activation, and finally convolution. A schematic comparison is presented in Figure 1 (left) of [2].
11+
In code, v1 refers to the ResNet defined in [1] but where a stride 2 is used on
12+
the 3x3 conv rather than the first 1x1 in the bottleneck. This change results
13+
in higher and more stable accuracy with less epochs than the original v1 and has
14+
shown to scale to higher batch sizes with minimal degradation in accuracy.
15+
There is no originating paper and the first mention we are aware of was in the
16+
[torch version of ResNetv1](https://github.com/facebook/fb.resnet.torch). Most
17+
popular v1 implementations are this implementation which we call ResNetv1.5. In
18+
testing we found v1.5 requires ~12% more compute to train and has 6% reduced
19+
throughput for inference compared to ResNetv1. Comparing the v1 model to the
20+
v1.5 model, which has happened in blog posts, is an apples-to-oranges
21+
comparison especially in regards to hardware or platform performance. CIFAR-10
22+
ResNet does not use the bottleneck and is not impacted by these nuances.
23+
24+
v2 refers to [2]. The principle difference between the two versions is that v1
25+
applies batch normalization and activation after convolution, while v2 applies
26+
batch normalization, then activation, and finally convolution. A schematic
27+
comparison is presented in Figure 1 (left) of [2].
1228

1329
Please proceed according to which dataset you would like to train/evaluate on:
1430

@@ -77,7 +93,7 @@ ResNet-50 v1 (Accuracy 75.91%):
7793
* [SavedModel](http://download.tensorflow.org/models/official/20180601_resnet_v1_imagenet_savedmodel.tar.gz)
7894

7995
### Transfer Learning
80-
You can use a pretrained model to initialize a training process. In addition you are able to freeze all but the final fully connected layers to fine tune your model. Transfer Learning is useful when training on your own small datasets. For a brief look at transfer learning in the context of convolutional neural networks, we recommend reading these [short notes](http://cs231n.github.io/transfer-learning/).
96+
You can use a pretrained model to initialize a training process. In addition you are able to freeze all but the final fully connected layers to fine tune your model. Transfer Learning is useful when training on your own small datasets. For a brief look at transfer learning in the context of convolutional neural networks, we recommend reading these [short notes](http://cs231n.github.io/transfer-learning/).
8197

8298

8399
To fine tune a pretrained resnet you must make three changes to your training procedure:

official/resnet/imagenet_main.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -323,7 +323,7 @@ def define_imagenet_flags():
323323
resnet_run_loop.define_resnet_flags(
324324
resnet_size_choices=['18', '34', '50', '101', '152', '200'])
325325
flags.adopt_module_key_flags(resnet_run_loop)
326-
flags_core.set_defaults(train_epochs=100)
326+
flags_core.set_defaults(train_epochs=90)
327327

328328

329329
def run_imagenet(flags_obj):

official/resnet/resnet_run_loop.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -519,7 +519,7 @@ def define_resnet_flags(resnet_size_choices=None):
519519
flags.adopt_module_key_flags(flags_core)
520520

521521
flags.DEFINE_enum(
522-
name='resnet_version', short_name='rv', default='2',
522+
name='resnet_version', short_name='rv', default='1',
523523
enum_values=['1', '2'],
524524
help=flags_core.help_wrap(
525525
'Version of ResNet. (1 or 2) See README.md for details.'))

0 commit comments

Comments
 (0)