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/03/08 22:19:53 UTC

[GitHub] [incubator-mxnet] abhinavs95 commented on a change in pull request #14351: [MXNet-1348][WIP][Fit API]Adding CNN examples for fit() API

abhinavs95 commented on a change in pull request #14351: [MXNet-1348][WIP][Fit API]Adding CNN examples for fit() API
URL: https://github.com/apache/incubator-mxnet/pull/14351#discussion_r263949755
 
 

 ##########
 File path: example/gluon/estimator_example/alexnet.py
 ##########
 @@ -0,0 +1,156 @@
+# 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.
+
+# This example is inspired from
+# https://github.com/d2l-ai/d2l-en/blob/master/chapter_convolutional-neural-networks/alexnet.md
+# Model definition is from
+# https://github.com/dmlc/gluon-cv/blob/master/gluoncv/model_zoo/alexnet.py
+
+
+import os
+import sys
+import argparse
+import mxnet as mx
+from mxnet import gluon
+from mxnet.gluon import nn, data
+from mxnet.gluon.block import HybridBlock
+from mxnet.gluon.estimator import estimator, event_handler
+
+def parse_args():
+    '''
+    Command Line Interface
+    '''
+    parser = argparse.ArgumentParser(description='Train ResNet18 on Fashion-MNIST')
+    parser.add_argument('--batch-size', type=int, default=128,
+                        help='training batch size per device (CPU/GPU).')
+    parser.add_argument('--num-epochs', type=int, default=1,
+                        help='number of training epochs.')
+    parser.add_argument('--input-size', type=int, default=224,
+                        help='size of the input image size. default is 224')
+    parser.add_argument('--lr', type=float, default=0.001,
+                        help='learning rate. default is 0.001')
+    parser.add_argument('-j', '--num-workers', default=None, type=int,
+                        help='number of preprocessing workers')
+    opt = parser.parse_args()
+    return opt
+
+class AlexNet(HybridBlock):
 
 Review comment:
   Yes. Since the gluon model zoo already has alexnet and resnet, I will import it from there.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to 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