项目地址:https://github.com/tensorflow/models/tree/master/official/resnet
首先将models
文件夹加入Python Path中,否则会报错ImportError: No module named official.resnet
$ export PYTHONPATH=$PYTHONPATH:models
查看cifar10_download_and_extract.py
的文档
$ python cifar10_download_and_extract.py --help
usage: cifar10_download_and_extract.py [-h] [--data_dir DATA_DIR]
optional arguments:
-h, --help show this help message and exit
--data_dir DATA_DIR Directory to download data and extract the tarball
开始下载数据,使用参数--data_dir
指定下载数据的文件夹
$ python cifar10_download_and_extract.py --data_dir=cifar_data
>> Downloading cifar-10-binary.tar.gz 100.0%
Successfully downloaded cifar-10-binary.tar.gz 170052171 bytes.
查看cifar10_main.py
的文档
$ python cifar10_main.py --help
Runs a ResNet model on the CIFAR-10 dataset.
flags:
models/official/resnet/cifar10_main.py:
-bs,--batch_size:
Batch size for training and evaluation. When using multiple gpus, this is
the
global batch size for all devices. For example, if the batch size is 32 and
there are 4 GPUs, each GPU will get 8 examples on each step.
(default: '128')
(an integer)
--[no]clean:
If set, model_dir will be removed if it exists.
(default: 'false')
-dd,--data_dir:
The location of the input data.
(default: '/tmp/cifar10_data')
-df,--data_format: <channels_first|channels_last>:
A flag to override the data format used in the model. channels_first
provides a
performance boost on GPU but is not always compatible with CPU. If left
unspecified, the data format will be chosen automatically based on whether
TensorFlow was built for CPU or GPU.
-ebe,--epochs_between_evals:
The number of training epochs to run between evaluations.
(default: '10')
(an integer)
--[no]eval_only:
Skip training and only perform evaluation on the latest checkpoint.
(default: 'false')
-ed,--export_dir:
If set, a SavedModel serialization of the model will be exported to this
directory at the end of training. See the README for more details and
relevant
links.
-ft,--[no]fine_tune:
If True do not train any parameters except for the final layer.
(default: 'false')
-hk,--hooks:
A list of (case insensitive) strings to specify the names of training hooks.
Hook:
loggingtensorhook
profilerhook
examplespersecondhook
loggingmetrichook
Example: `--hooks ProfilerHook,ExamplesPerSecondHook`
See official.utils.logs.hooks_helper for details.
(default: 'LoggingTensorHook')
(a comma separated list)
--[no]image_bytes_as_serving_input:
If True exports savedmodel with serving signature that accepts JPEG image
bytes
instead of a fixed size [HxWxC] tensor that represents the image. The former
is
easier to use for serving at the expense of image resize/cropping being done
as
part of model inference. Note, this flag only applies to ImageNet and cannot
be
used for CIFAR.
(default: 'false')
-md,--model_dir:
The location of the model checkpoint files.
(default: '/tmp/cifar10_model')
-pmcp,--pretrained_model_checkpoint_path:
If not None initialize all the network except the final layer with these
values
-rs,--resnet_size:
The size of the ResNet model to use.
(default: '56')
-rv,--resnet_version: <1|2>:
Version of ResNet. (1 or 2) See README.md for details.
(default: '1')
-te,--train_epochs:
The number of epochs used to train.
(default: '182')
(an integer)
Try --helpfull to get a list of all flags.