You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mxnet.apache.org by jx...@apache.org on 2018/01/16 19:51:45 UTC
[incubator-mxnet] branch master updated: correct usage of bool
arguments from command line (#8880)
This is an automated email from the ASF dual-hosted git repository.
jxie pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-mxnet.git
The following commit(s) were added to refs/heads/master by this push:
new 89b4fa0 correct usage of bool arguments from command line (#8880)
89b4fa0 is described below
commit 89b4fa0648405d755355957f99a2c794a3555f46
Author: Rahul Huilgol <ra...@gmail.com>
AuthorDate: Tue Jan 16 11:51:41 2018 -0800
correct usage of bool arguments from command line (#8880)
* correct boolean args in arg parsing
Signed-off-by: Rahul <ra...@gmail.com>
* remove print
Signed-off-by: Rahul <ra...@gmail.com>
* remove debug changes
Signed-off-by: Rahul <ra...@gmail.com>
* using store_true/false
Signed-off-by: Rahul <ra...@gmail.com>
---
example/caffe/caffe_net.py | 4 ++--
example/cnn_chinese_text_classification/text_cnn.py | 4 ++--
example/cnn_text_classification/text_cnn.py | 4 ++--
example/reinforcement-learning/dqn/dqn_demo.py | 4 ++--
example/rnn/bucketing/cudnn_lstm_bucketing.py | 4 ++--
example/ssd/demo.py | 8 ++++----
example/ssd/deploy.py | 4 ++--
example/ssd/evaluate.py | 8 ++++----
example/ssd/tools/prepare_dataset.py | 4 ++--
example/ssd/train.py | 8 ++++----
tools/im2rec.py | 15 ++++++++-------
11 files changed, 34 insertions(+), 33 deletions(-)
diff --git a/example/caffe/caffe_net.py b/example/caffe/caffe_net.py
index 0dc4770..0459c90 100644
--- a/example/caffe/caffe_net.py
+++ b/example/caffe/caffe_net.py
@@ -77,8 +77,8 @@ def parse_args():
help='the cnn to use (mlp | lenet | <path to network json file>')
parser.add_argument('--caffe-loss', type=int, default=0,
help='Use CaffeLoss symbol')
- parser.add_argument('--caffe-data', type=bool, default=False,
- help='Use Caffe input-data layer (True | False)')
+ parser.add_argument('--caffe-data', action='store_true',
+ help='Use Caffe input-data layer only if specified')
parser.add_argument('--data-dir', type=str, default='mnist/',
help='the input data directory')
parser.add_argument('--gpus', type=str,
diff --git a/example/cnn_chinese_text_classification/text_cnn.py b/example/cnn_chinese_text_classification/text_cnn.py
index 2a78fd2..4598a52 100644
--- a/example/cnn_chinese_text_classification/text_cnn.py
+++ b/example/cnn_chinese_text_classification/text_cnn.py
@@ -38,8 +38,8 @@ logger = logging.getLogger(__name__)
parser = argparse.ArgumentParser(description="CNN for text classification",
formatter_class=argparse.ArgumentDefaultsHelpFormatter)
-parser.add_argument('--pretrained-embedding', type=bool, default=False,
- help='use pre-trained word2vec')
+parser.add_argument('--pretrained-embedding', action='store_true',
+ help='use pre-trained word2vec only if specified')
parser.add_argument('--num-embed', type=int, default=300,
help='embedding layer size')
parser.add_argument('--gpus', type=str, default='',
diff --git a/example/cnn_text_classification/text_cnn.py b/example/cnn_text_classification/text_cnn.py
index d88a8e6..9ad9443 100644
--- a/example/cnn_text_classification/text_cnn.py
+++ b/example/cnn_text_classification/text_cnn.py
@@ -31,8 +31,8 @@ logging.basicConfig(level=logging.DEBUG)
parser = argparse.ArgumentParser(description="CNN for text classification",
formatter_class=argparse.ArgumentDefaultsHelpFormatter)
-parser.add_argument('--pretrained-embedding', type=bool, default=False,
- help='use pre-trained word2vec')
+parser.add_argument('--pretrained-embedding', action='store_true',
+ help='use pre-trained word2vec only if specified')
parser.add_argument('--num-embed', type=int, default=300,
help='embedding layer size')
parser.add_argument('--gpus', type=str, default='',
diff --git a/example/reinforcement-learning/dqn/dqn_demo.py b/example/reinforcement-learning/dqn/dqn_demo.py
index 750da7a..8655d5c 100644
--- a/example/reinforcement-learning/dqn/dqn_demo.py
+++ b/example/reinforcement-learning/dqn/dqn_demo.py
@@ -55,8 +55,8 @@ def main():
help='Eps of the AdaGrad optimizer')
parser.add_argument('--clip-gradient', required=False, type=float, default=None,
help='Clip threshold of the AdaGrad optimizer')
- parser.add_argument('--double-q', required=False, type=bool, default=False,
- help='Use Double DQN')
+ parser.add_argument('--double-q', action='store_true',
+ help='Use Double DQN only if specified')
parser.add_argument('--wd', required=False, type=float, default=0.0,
help='Weight of the L2 Regularizer')
parser.add_argument('-c', '--ctx', required=False, type=str, default='gpu',
diff --git a/example/rnn/bucketing/cudnn_lstm_bucketing.py b/example/rnn/bucketing/cudnn_lstm_bucketing.py
index e9c3237..84cfc9d 100644
--- a/example/rnn/bucketing/cudnn_lstm_bucketing.py
+++ b/example/rnn/bucketing/cudnn_lstm_bucketing.py
@@ -33,8 +33,8 @@ parser.add_argument('--num-hidden', type=int, default=200,
help='hidden layer size')
parser.add_argument('--num-embed', type=int, default=200,
help='embedding layer size')
-parser.add_argument('--bidirectional', type=bool, default=False,
- help='whether to use bidirectional layers')
+parser.add_argument('--bidirectional', action='store_true',
+ help='uses bidirectional layers if specified')
parser.add_argument('--gpus', type=str,
help='list of gpus to run, e.g. 0 or 0,2,5. empty means using cpu. ' \
'Increase batch size when using multiple gpus for best performance.')
diff --git a/example/ssd/demo.py b/example/ssd/demo.py
index 965f2ec..8106eb5 100644
--- a/example/ssd/demo.py
+++ b/example/ssd/demo.py
@@ -88,10 +88,10 @@ def parse_args():
help='object visualize score threshold, default 0.6')
parser.add_argument('--nms', dest='nms_thresh', type=float, default=0.5,
help='non-maximum suppression threshold, default 0.5')
- parser.add_argument('--force', dest='force_nms', type=bool, default=True,
- help='force non-maximum suppression on different class')
- parser.add_argument('--timer', dest='show_timer', type=bool, default=True,
- help='show detection time')
+ parser.add_argument('--no-force', dest='force_nms', action='store_false',
+ help='dont force non-maximum suppression on different class')
+ parser.add_argument('--no-timer', dest='show_timer', action='store_false',
+ help='dont show detection time')
parser.add_argument('--deploy', dest='deploy_net', action='store_true', default=False,
help='Load network from json file, rather than from symbol')
parser.add_argument('--class-names', dest='class_names', type=str,
diff --git a/example/ssd/deploy.py b/example/ssd/deploy.py
index a20e8a7..5c435f4 100644
--- a/example/ssd/deploy.py
+++ b/example/ssd/deploy.py
@@ -38,8 +38,8 @@ def parse_args():
default=20, type=int)
parser.add_argument('--nms', dest='nms_thresh', type=float, default=0.5,
help='non-maximum suppression threshold, default 0.5')
- parser.add_argument('--force', dest='force_nms', type=bool, default=True,
- help='force non-maximum suppression on different class')
+ parser.add_argument('--no-force', dest='force_nms', action='store_false',
+ help='dont force non-maximum suppression on different class')
parser.add_argument('--topk', dest='nms_topk', type=int, default=400,
help='apply nms only to top k detections based on scores.')
args = parser.parse_args()
diff --git a/example/ssd/evaluate.py b/example/ssd/evaluate.py
index 4e7f0a4..d1a83cc 100644
--- a/example/ssd/evaluate.py
+++ b/example/ssd/evaluate.py
@@ -59,12 +59,12 @@ def parse_args():
help='non-maximum suppression threshold')
parser.add_argument('--overlap', dest='overlap_thresh', type=float, default=0.5,
help='evaluation overlap threshold')
- parser.add_argument('--force', dest='force_nms', type=bool, default=False,
+ parser.add_argument('--force', dest='force_nms', action='store_true',
help='force non-maximum suppression on different class')
- parser.add_argument('--use-difficult', dest='use_difficult', type=bool, default=False,
+ parser.add_argument('--use-difficult', dest='use_difficult', action='store_true',
help='use difficult ground-truths in evaluation')
- parser.add_argument('--voc07', dest='use_voc07_metric', type=bool, default=True,
- help='use PASCAL VOC 07 metric')
+ parser.add_argument('--no-voc07', dest='use_voc07_metric', action='store_false',
+ help='dont use PASCAL VOC 07 metric')
parser.add_argument('--deploy', dest='deploy_net', help='Load network from model',
action='store_true', default=False)
args = parser.parse_args()
diff --git a/example/ssd/tools/prepare_dataset.py b/example/ssd/tools/prepare_dataset.py
index 9b4fceb..6dc95e6 100644
--- a/example/ssd/tools/prepare_dataset.py
+++ b/example/ssd/tools/prepare_dataset.py
@@ -102,8 +102,8 @@ def parse_args():
parser.add_argument('--root', dest='root_path', help='dataset root path',
default=os.path.join(curr_path, '..', 'data', 'VOCdevkit'),
type=str)
- parser.add_argument('--shuffle', dest='shuffle', help='shuffle list',
- type=bool, default=True)
+ parser.add_argument('--no-shuffle', dest='shuffle', help='shuffle list',
+ action='store_false')
args = parser.parse_args()
return args
diff --git a/example/ssd/train.py b/example/ssd/train.py
index 1648c82..1ad70bd 100644
--- a/example/ssd/train.py
+++ b/example/ssd/train.py
@@ -95,12 +95,12 @@ def parse_args():
help='non-maximum suppression threshold')
parser.add_argument('--overlap', dest='overlap_thresh', type=float, default=0.5,
help='evaluation overlap threshold')
- parser.add_argument('--force', dest='force_nms', type=bool, default=False,
+ parser.add_argument('--force', dest='force_nms', action='store_true',
help='force non-maximum suppression on different class')
- parser.add_argument('--use-difficult', dest='use_difficult', type=bool, default=False,
+ parser.add_argument('--use-difficult', dest='use_difficult', action='store_true',
help='use difficult ground-truths in evaluation')
- parser.add_argument('--voc07', dest='use_voc07_metric', type=bool, default=True,
- help='use PASCAL VOC 07 11-point metric')
+ parser.add_argument('--no-voc07', dest='use_voc07_metric', action='store_false',
+ help='dont use PASCAL VOC 07 11-point metric')
args = parser.parse_args()
return args
diff --git a/tools/im2rec.py b/tools/im2rec.py
index f94c5c0..5547c53 100644
--- a/tools/im2rec.py
+++ b/tools/im2rec.py
@@ -211,7 +211,7 @@ def parse_args():
parser.add_argument('root', help='path to folder containing images.')
cgroup = parser.add_argument_group('Options for creating image lists')
- cgroup.add_argument('--list', type=bool, default=False,
+ cgroup.add_argument('--list', action='store_true',
help='If this is set im2rec will create image list(s) by traversing root folder\
and output to <prefix>.lst.\
Otherwise im2rec will read <prefix>.lst and create a database at <prefix>.rec')
@@ -222,20 +222,21 @@ def parse_args():
help='Ratio of images to use for training.')
cgroup.add_argument('--test-ratio', type=float, default=0,
help='Ratio of images to use for testing.')
- cgroup.add_argument('--recursive', type=bool, default=False,
+ cgroup.add_argument('--recursive', action='store_true',
help='If true recursively walk through subdirs and assign an unique label\
to images in each folder. Otherwise only include images in the root folder\
and give them label 0.')
- cgroup.add_argument('--shuffle', type=bool, default=True, help='If this is set as True, \
- im2rec will randomize the image order in <prefix>.lst')
+ cgroup.add_argument('--no-shuffle', dest='shuffle', action='store_false',
+ help='If this is passed, \
+ im2rec will not randomize the image order in <prefix>.lst')
rgroup = parser.add_argument_group('Options for creating database')
- rgroup.add_argument('--pass-through', type=bool, default=False,
+ rgroup.add_argument('--pass-through', action='store_true',
help='whether to skip transformation and save image as is')
rgroup.add_argument('--resize', type=int, default=0,
help='resize the shorter edge of image to the newsize, original images will\
be packed by default.')
- rgroup.add_argument('--center-crop', type=bool, default=False,
+ rgroup.add_argument('--center-crop', action='store_true',
help='specify whether to crop the center image to make it rectangular.')
rgroup.add_argument('--quality', type=int, default=95,
help='JPEG quality for encoding, 1-100; or PNG compression for encoding, 1-9')
@@ -250,7 +251,7 @@ def parse_args():
-1:Loads image as such including alpha channel.')
rgroup.add_argument('--encoding', type=str, default='.jpg', choices=['.jpg', '.png'],
help='specify the encoding of the images.')
- rgroup.add_argument('--pack-label', type=bool, default=False,
+ rgroup.add_argument('--pack-label', action='store_true',
help='Whether to also pack multi dimensional label in the record file')
args = parser.parse_args()
args.prefix = os.path.abspath(args.prefix)
--
To stop receiving notification emails like this one, please contact
['"commits@mxnet.apache.org" <co...@mxnet.apache.org>'].