**NOTE: For the most part, you will find a newer version of this code at [models/research/slim](https://github.com/tensorflow/models/tree/master/research/slim).** In particular:
* `inception_train.py` and `imagenet_train.py` should no longer be used. The slim editions for running on multiple GPUs are the current best examples.
* `inception_distributed_train.py` and `imagenet_distributed_train.py` are still valid examples of distributed training.
For performance benchmarking, please see https://www.tensorflow.org/performance/benchmarks.
---
# Inception in TensorFlow
[ImageNet](http://www.image-net.org/) is a common academic data set in machine
learning for training an image recognition system. Code in this directory
demonstrates how to use TensorFlow to train and evaluate a type of convolutional
neural network (CNN) on this academic data set. In particular, we demonstrate
how to train the Inception v3 architecture as specified in:
_Rethinking the Inception Architecture for Computer Vision_
Christian Szegedy, Vincent Vanhoucke, Sergey Ioffe, Jonathon Shlens, Zbigniew
Wojna
http://arxiv.org/abs/1512.00567
This network achieves 21.2% top-1 and 5.6% top-5 error for single frame
evaluation with a computational cost of 5 billion multiply-adds per inference
and with using less than 25 million parameters. Below is a visualization of the
model architecture.
![Inception-v3 Architecture](g3doc/inception_v3_architecture.png)
## Description of Code
The code base provides three core binaries for:
* Training an Inception v3 network from scratch across multiple GPUs and/or
multiple machines using the ImageNet 2012 Challenge training data set.
* Evaluating an Inception v3 network using the ImageNet 2012 Challenge
validation data set.
* Retraining an Inception v3 network on a novel task and back-propagating the
errors to fine tune the network weights.
The training procedure employs synchronous stochastic gradient descent across
multiple GPUs. The user may specify the number of GPUs they wish to harness. The
synchronous training performs *batch-splitting* by dividing a given batch across
multiple GPUs.
The training set up is nearly identical to the section [Training a Model Using
Multiple GPU Cards](https://www.tensorflow.org/tutorials/deep_cnn/index.html#launching_and_training_the_model_on_multiple_gpu_cards)
where we have substituted the CIFAR-10 model architecture with Inception v3. The
primary differences with that setup are:
* Calculate and update the batch-norm statistics during training so that they
may be substituted in during evaluation.
* Specify the model architecture using a (still experimental) higher level
language called TensorFlow-Slim.
For more details about TensorFlow-Slim, please see the [Slim README](inception/slim/README.md). Please note that this higher-level language is still
*experimental* and the API may change over time depending on usage and
subsequent research.
## Getting Started
Before you run the training script for the first time, you will need to download
and convert the ImageNet data to native TFRecord format. The TFRecord format
consists of a set of sharded files where each entry is a serialized `tf.Example`
proto. Each `tf.Example` proto contains the ImageNet image (JPEG encoded) as
well as metadata such as label and bounding box information. See
[`parse_example_proto`](inception/image_processing.py) for details.
We provide a single [script](inception/data/download_and_preprocess_imagenet.sh) for
downloading and converting ImageNet data to TFRecord format. Downloading and
preprocessing the data may take several hours (up to half a day) depending on
your network and computer speed. Please be patient.
To begin, you will need to sign up for an account with [ImageNet](http://image-net.org) to gain access to the data. Look for the sign up page,
create an account and request an access key to download the data.
After you have `USERNAME` and `PASSWORD`, you are ready to run our script. Make
sure that your hard disk has at least 500 GB of free space for downloading and
storing the data. Here we select `DATA_DIR=$HOME/imagenet-data` as such a
location but feel free to edit accordingly.
When you run the below script, please enter *USERNAME* and *PASSWORD* when
prompted. This will occur at the very beginning. Once these values are entered,
you will not need to interact with the script again.
```shell
# location of where to place the ImageNet data
DATA_DIR=$HOME/imagenet-data
# build the preprocessing script.
cd tensorflow-models/inception
bazel build //inception:download_and_preprocess_imagenet
# run it
bazel-bin/inception/download_and_preprocess_imagenet "${DATA_DIR}"
```
The final line of the output script should read:
```shell
2016-02-17 14:30:17.287989: Finished writing all 1281167 images in data set.
```
When the script finishes, you will find 1024 training files and 128 validation
files in the `DATA_DIR`. The files will match the patterns
`train-?????-of-01024` and `validation-?????-of-00128`, respectively.
[Congratulations!](https://www.youtube.com/watch?v=9bZkp7q19f0) You are now
ready to train or evaluate with the ImageNet data set.
## How to Train from Scratch
**WARNING** Training an Inception v3 network from scratch is a computationally
intensive task and depending on your compute setup may take several days or even
weeks.
*Before proceeding* please read the [Convolutional Neural Networks](https://www.tensorflow.org/tutorials/deep_cnn/index.html) tutorial; in
particular, focus on [Training a Model Using Multiple GPU Cards](https://www.tensorflow.org/tutorials/deep_cnn/index.html#launching_and_training_the_model_on_multiple_gpu_cards). The model training method is nearly identical to that described in the
CIFAR-10 multi-GPU model training. Briefly, the model training
* Places an individual model replica on each GPU.
* Splits the batch across the GPUs.
* Updates model parameters synchronously by waiting for all GPUs to finish
processing a batch of data.
The training procedure is encapsulated by this diagram of how operations and
variables are placed on CPU and GPUs respectively.
<div style="width:40%; margin:auto; margin-bottom:10px; margin-top:20px;">
<img style="width:100%" src="https://www.tensorflow.org/images/Parallelism.png">
</div>
Each tower computes the gradients for a portion of the batch and the gradients
are combined and averaged across the multiple towers in order to provide a
single update of the Variables stored on the CPU.
A crucial aspect of training a network of this size is *training speed* in terms
of wall-clock time. The training speed is dictated by many factors -- most
importantly the batch size and the learning rate schedule. Both of these
parameters are heavily coupled to the hardware set up.
Generally speaking, a batch size is a difficult parameter to tune as it requires
balancing memory demands of the model, memory available on the GPU and speed of
computation. Generally speaking, employing larger batch sizes leads to more
efficient computation and potentially more efficient training steps.
We have tested several hardware setups for training this model from scratch but
we emphasize that depending your hardware set up, you may need to adapt the
batch size and learning rate schedule.
Please see the comments in `inception_train.py` for a few selected learning rate
plans based on some selected hardware setups.
To train this model, you simply need to specify the following:
```shell
# Build the model. Note that we need to make sure the TensorFlow is ready to
# use before this as this command will not build TensorFlow.
cd tensorflow-models/inception
bazel build //inception:imagenet_train
# run it
bazel-bin/inception/imagenet_train --num_gpus=1 --batch_size=32 --train_dir=/tmp/imagenet_train --data_dir=/tmp/imagenet_data
```
The model reads in the ImageNet training data from `--data_dir`. If you followed
the instructions in [Gett
没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
收起资源包目录
毕业设计项目,一个能检测AI人脸合成图像的系统。.zip (2000个子文件)
mobile_ssd_client.h 9KB
ssd_utils.h 6KB
mobile_ssd_tflite_client.h 4KB
mobile_lstd_tflite_client.h 3KB
conversion_utils.h 2KB
file_utils.h 1KB
request.json 138KB
benchmark_run.json 10KB
coco_gt.json 4KB
coco_pred.json 4KB
benchmark_metric.json 1KB
basic.json 633B
bayesian.json 491B
model.json 355B
benchmark_run_status.json 307B
steve_cov.json 296B
dense_prediction_cell_branch5_top1_cityscapes.json 289B
steve.json 267B
mve_mean.json 221B
mve_tdlambda.json 221B
mve_tdk.json 217B
flagrun.json 209B
hardcore.json 204B
rshum.json 202B
mve_25tdlambda1.json 195B
mve_25tdlambda2.json 195B
mve_75tdlambda2.json 195B
mve_75tdlambda0.json 195B
mve_75tdlambda1.json 195B
mve_25tdlambda0.json 195B
halfcheetah.json 194B
humanoid.json 193B
walker2d.json 191B
swimmer.json 189B
hopper.json 189B
steve_1h2.json 184B
steve_5h0.json 184B
steve_1h1.json 184B
steve_5h1.json 184B
steve_5h2.json 184B
steve_2h2.json 184B
steve_2h1.json 184B
steve_1h0.json 184B
steve_2h0.json 184B
speedrun.json 173B
speedy_mve_tdk0.json 117B
speedy_mve_tdk1.json 117B
speedy_mve_tdk0.json 116B
speedy_mve_tdk1.json 116B
speedy_steve1.json 115B
speedy_steve0.json 115B
speedy_steve1.json 114B
speedy_steve0.json 114B
speedy_ddpg1.json 114B
speedy_ddpg0.json 114B
speedy_ddpg1.json 113B
speedy_ddpg0.json 113B
ensemble_mve_tdk2.json 97B
ensemble_mve_tdk0.json 97B
ensemble_mve_tdk1.json 97B
train_config.json 93B
mve_tdk1.json 76B
mve_tdk3.json 76B
mve_tdk2.json 76B
mve_tdk0.json 76B
steve_cov1.json 75B
steve_cov2.json 75B
steve_cov0.json 75B
mve_meank1.json 74B
mve_meank0.json 74B
mve_meank2.json 74B
steve3.json 74B
steve2.json 74B
steve1.json 74B
steve0.json 74B
mve_tdk1.json 73B
mve_tdk3.json 73B
mve_tdk2.json 73B
mve_tdk0.json 73B
ddpg0.json 73B
ddpg3.json 73B
ddpg1.json 73B
ddpg2.json 73B
mve_tdk1.json 73B
mve_tdk3.json 73B
mve_tdk2.json 73B
mve_tdk0.json 73B
mve_tdk1.json 73B
mve_tdk3.json 73B
mve_tdk2.json 73B
mve_tdk0.json 73B
input_config.json 73B
mve_tdk1.json 72B
mve_tdk3.json 72B
mve_tdk2.json 72B
mve_tdk0.json 72B
mve_tdk1.json 72B
mve_tdk3.json 72B
mve_tdk2.json 72B
mve_tdk0.json 72B
共 2000 条
- 1
- 2
- 3
- 4
- 5
- 6
- 20
资源评论
马coder
- 粉丝: 1203
- 资源: 6602
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- vscode配置c/c 环境教程
- vscode配置c/c 环境教程
- 基于matlab实现电磁优化计算功能,进行线型规划优化电磁设计.rar
- 基于matlab实现带精英策略的非支配排序遗传算法matlab 源码.rar
- 基于matlab实现差分进化算法,最新的用于替代遗传算法,是以后的主要发展方法.rar
- VSCode配置c/c++环境教程.md
- 基于matlab实现标准合作型协同进化遗传算法matlab源程序
- 七下人教.zip
- 基于matlab实现本份代码能对图像进行gabor滤波处理,结合指纹方向图以及指纹沟壑频率特性,对指纹图像进行增强.rar
- 基于matlab实现RBM神经网络实现了手写数字体识别的GUI程序.rar
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功