You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mxnet.apache.org by GitBox <gi...@apache.org> on 2019/01/17 12:46:11 UTC

[GitHub] larroy commented on a change in pull request #13895: Add a inference script providing both accuracy and benchmark result for original wide_n_deep example

larroy commented on a change in pull request #13895: Add a inference script providing both accuracy and benchmark result for original wide_n_deep example
URL: https://github.com/apache/incubator-mxnet/pull/13895#discussion_r248655828
 
 

 ##########
 File path: example/sparse/wide_deep/inference.py
 ##########
 @@ -0,0 +1,121 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+import mxnet as mx
+from mxnet.test_utils import *
+from data import get_uci_adult
+from model import wide_deep_model
+import argparse
+import os
+import time
+
+parser = argparse.ArgumentParser(description="Run sparse wide and deep inference",
+                                 formatter_class=argparse.ArgumentDefaultsHelpFormatter)
+parser.add_argument('--num-infer-batch', type=int, default=100,
+                    help='number of batches to inference')
+parser.add_argument('--load-epoch', type=int, default=0,
+                    help='loading the params of the corresponding training epoch.')
+parser.add_argument('--batch-size', type=int, default=100,
+                    help='number of examples per batch')
+parser.add_argument('--accuracy', action='store_true', default=False,
+                    help='run the script for inference accuracy, not set for benchmark.')
+parser.add_argument('--verbose', action='store_true', default=False,
+                    help='accurcy for each batch will be logged if set')
+parser.add_argument('--cuda', action='store_true', default=False,
+                    help='Train on GPU with CUDA')
+parser.add_argument('--model-prefix', type=str, default='checkpoint',
+                    help='the model prefix')
+
+# Related to feature engineering, please see preprocess in data.py
+ADULT = {
+    'train': 'adult.data',
+    'test': 'adult.test',
+    'url': 'https://archive.ics.uci.edu/ml/machine-learning-databases/adult/',
+    'num_linear_features': 3000,
+    'num_embed_features': 2,
+    'num_cont_features': 38,
+    'embed_input_dims': [1000, 1000],
+    'hidden_units': [8, 50, 100],
+}
+
+if __name__ == '__main__':
 
 Review comment:
   could we wrap it into a main function as:
   
   ```
   if __name__ == '__main__':
       sys.exit(main())
   ```

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services