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

Skip to content

Commit 7af1ceb

Browse files
authored
Merge pull request tensorflow#5434 from tfboyd/tpu_imagenet
link to non-deprecated imagenet preprocessing script
2 parents fe54563 + 0c74ba6 commit 7af1ceb

File tree

1 file changed

+28
-20
lines changed

1 file changed

+28
-20
lines changed

official/resnet/README.md

Lines changed: 28 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
# ResNet in TensorFlow
22

3-
Deep residual networks, or ResNets for short, provided the breakthrough idea of identity mappings in order to enable training of very deep convolutional neural networks. This folder contains an implementation of ResNet for the ImageNet dataset written in TensorFlow.
3+
Deep residual networks, or ResNets for short, provided the breakthrough idea of
4+
identity mappings in order to enable training of very deep convolutional neural
5+
networks. This folder contains an implementation of ResNet for the ImageNet
6+
dataset written in TensorFlow.
47

58
See the following papers for more background:
69

@@ -12,14 +15,13 @@ In code, v1 refers to the ResNet defined in [1] but where a stride 2 is used on
1215
the 3x3 conv rather than the first 1x1 in the bottleneck. This change results
1316
in higher and more stable accuracy with less epochs than the original v1 and has
1417
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.
18+
There is no originating paper. The first mention we are aware of was in the
19+
torch version of [ResNetv1](https://github.com/facebook/fb.resnet.torch). Most
20+
popular v1 implementations are this implementation which we call ResNetv1.5.
21+
22+
In testing we found v1.5 requires ~12% more compute to train and has 6% reduced
23+
throughput for inference compared to ResNetv1. CIFAR-10 ResNet does not use the
24+
bottleneck and is thus the same for v1 as v1.5.
2325

2426
v2 refers to [2]. The principle difference between the two versions is that v1
2527
applies batch normalization and activation after convolution, while v2 applies
@@ -38,14 +40,11 @@ First make sure you've [added the models folder to your Python path](/official/#
3840

3941
Then download and extract the CIFAR-10 data from Alex's website, specifying the location with the `--data_dir` flag. Run the following:
4042

41-
```
43+
```bash
4244
python cifar10_download_and_extract.py
43-
```
44-
45-
Then to train the model, run the following:
46-
47-
```
45+
# Then to train the model, run the following:
4846
python cifar10_main.py
47+
4948
```
5049

5150
Use `--data_dir` to specify the location of the CIFAR-10 data used in the previous step. There are more flag options as described in `cifar10_main.py`.
@@ -54,23 +53,32 @@ Use `--data_dir` to specify the location of the CIFAR-10 data used in the previo
5453
## ImageNet
5554

5655
### Setup
57-
To begin, you will need to download the ImageNet dataset and convert it to TFRecord format. Follow along with the [Inception guide](https://github.com/tensorflow/models/tree/master/research/inception#getting-started) in order to prepare the dataset.
56+
To begin, you will need to download the ImageNet dataset and convert it to
57+
TFRecord format. The following [script](https://github.com/tensorflow/tpu/blob/master/tools/datasets/imagenet_to_gcs.py)
58+
and [README](https://github.com/tensorflow/tpu/tree/master/tools/datasets#imagenet_to_gcspy)
59+
provide a few options.
5860

5961
Once your dataset is ready, you can begin training the model as follows:
6062

61-
```
63+
```bash
6264
python imagenet_main.py --data_dir=/path/to/imagenet
6365
```
6466

65-
The model will begin training and will automatically evaluate itself on the validation data roughly once per epoch.
67+
The model will begin training and will automatically evaluate itself on the
68+
validation data roughly once per epoch.
6669

67-
Note that there are a number of other options you can specify, including `--model_dir` to choose where to store the model and `--resnet_size` to choose the model size (options include ResNet-18 through ResNet-200). See [`resnet.py`](resnet.py) for the full list of options.
70+
Note that there are a number of other options you can specify, including
71+
`--model_dir` to choose where to store the model and `--resnet_size` to choose
72+
the model size (options include ResNet-18 through ResNet-200). See
73+
[`resnet.py`](resnet.py) for the full list of options.
6874

6975

7076
## Compute Devices
7177
Training is accomplished using the DistributionStrategies API. (https://github.com/tensorflow/tensorflow/blob/master/tensorflow/contrib/distribute/README.md)
7278

73-
The appropriate distribution strategy is chosen based on the `--num_gpus` flag. By default this flag is one if TensorFlow is compiled with CUDA, and zero otherwise.
79+
The appropriate distribution strategy is chosen based on the `--num_gpus` flag.
80+
By default this flag is one if TensorFlow is compiled with CUDA, and zero
81+
otherwise.
7482

7583
num_gpus:
7684
+ 0: Use OneDeviceStrategy and train on CPU.

0 commit comments

Comments
 (0)