Ishitori commented on a change in pull request #11651: Add logistic regression tutorial URL: https://github.com/apache/incubator-mxnet/pull/11651#discussion_r203199799
########## File path: docs/tutorials/gluon/logistic_regression_explained.md ########## @@ -0,0 +1,215 @@ + +# Logistic regression using Gluon API explained + +Logistic Regression is one of the first models newcomers to Deep Learning are implementing. In this tutorial I am going to focus on how to do logistic regression using Gluon API and provide some high level tips. + +Before anything else, let's import required packages for this tutorial. + + +```python +import numpy as np +import mxnet as mx +from mxnet import nd, autograd, gluon +from mxnet.gluon import nn, Trainer +from mxnet.gluon.data import DataLoader, ArrayDataset + +mx.random.seed(12345) # Added for reproducibility +``` + +In this tutorial we will use fake dataset, which contains 10 features drawn from a normal distribution with mean equals to 0 and standard deviation equals to 1, and a class label, which can be either 0 or 1. The length of the dataset is an arbitrary value. The function below helps us to generate a dataset. + + +```python +def get_random_data(size, ctx): + x = nd.normal(0, 1, shape=(size, 10), ctx=ctx) + # Class label is generated via non-random logic so the network would have a pattern to look for + # Number 3 is selected to make sure that number of positive examples smaller than negative, but not too small + y = x.sum(axis=1) > 3 + return x, y +``` + +Also, let's define a set of hyperparameters, that we are going to use later. Since our model is simple and dataset is small, we are going to use CPU for calculations. Feel free to change it to GPU for a more advanced scenario. + + +```python +ctx = mx.cpu() +train_data_size = 1000 +val_data_size = 100 +batch_size = 10 +``` + +## Working with data + +To work with data, Apache MXNet provides Dataset and DataLoader classes. The former is used to provide an indexed access to the data, the latter is used to shuffle and batchify the data. Review comment: Yes, added links and remove my explanation. Added a link to Datasets and Dataloaders tutorial instead. ---------------------------------------------------------------- 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
