anirudhacharya commented on a change in pull request #12542: [MXNET-949] Module 
API to Gluon API tutorial
URL: https://github.com/apache/incubator-mxnet/pull/12542#discussion_r231695239
 
 

 ##########
 File path: docs/tutorials/python/module_to_gluon.md
 ##########
 @@ -0,0 +1,358 @@
+
+# Converting Module API code to the Gluon API
+
+Sometimes, you find yourself in the situation where the model you want to use 
has been written using the symbolic Module API rather than the simpler, 
easier-to-debug, more flexible, imperative Gluon API. In this tutorial, we will 
give you a comprehensive guide you can use in order to see how you can 
transform your Module code, to work with the Gluon API.
+
+The different steps to take into consideration are:
+
+I) Data loading
+
+II) Model definition
+
+III) Loss
+
+IV) Training Loop
+
+V) Exporting Models
+
+VI) Loading Models for Inference
+
+In the following section we will look at 1:1 mappings between the Module and 
the Gluon ways of training a neural networks.
+
+## I - Data Loading
+
+
+```python
+from collections import namedtuple
+import logging
+logging.basicConfig(level=logging.INFO)
+
+import numpy as np
+import mxnet as mx
+from mxnet.gluon.data import ArrayDataset, DataLoader
+from mxnet.gluon import nn
+from mxnet import gluon
+
+batch_size = 5
+dataset_length = 50
+```
+
+#### Module
+
+When using the Module API we use a 
[`DataIter`](https://mxnet.incubator.apache.org/api/python/io/io.html?highlight=dataiter#mxnet.io.DataIter),
 in addition to the data itself, the 
[`DataIter`](https://mxnet.incubator.apache.org/api/python/io/io.html?highlight=dataiter#mxnet.io.DataIter)
 contains information about the name of the input symbols.
+
+Let's create some random data, following the same format as grayscale 28x28 
images.
+
+
+```python
+train_data = np.random.rand(dataset_length, 28,28).astype('float32')
 
 Review comment:
   should we set the seed here, for reproducibility?

----------------------------------------------------------------
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:
[email protected]


With regards,
Apache Git Services

Reply via email to