|
28 | 28 | "## Introduction\n",
|
29 | 29 | "In this notebook, we will train a neural network locally on the location from where this notebook is run using MXNet. We will then see how to create an endpoint from the trained MXNet model and deploy it on SageMaker. We will then inference from the newly created SageMaker endpoint. \n",
|
30 | 30 | "\n",
|
31 |
| - "The neural network that we will use is a simple fully-connected neural network. The definition of the neural network can be found in the accompanying [mnist.py](mnist.py) file. The ``build_graph`` method contains the model defnition (shown below).\n", |
| 31 | + "The neural network that we will use is a simple fully-connected neural network. The definition of the neural network can be found in the accompanying [mnist.py](mnist.py) file. The ``build_graph`` method contains the model definition (shown below).\n", |
32 | 32 | "\n",
|
33 | 33 | "```python\n",
|
34 | 34 | "def build_graph():\n",
|
|
98 | 98 | "source": [
|
99 | 99 | "### Training\n",
|
100 | 100 | "\n",
|
101 |
| - "It is time to train the network. Since we are training the network locally, we can make use of mxnet training tools. The training method is also in the accompanying [mnist.py](mnist.py) file. The notebook assumes that this instance is a `p2.xlarge`. If running this in a non-GPU notebook instance, please adjust num_gpus=0 and num_cpu=1 The method is shown below. \n", |
| 101 | + "It is time to train the network. Since we are training the network locally, we can make use of mxnet training tools. The training method is also in the accompanying [mnist.py](mnist.py) file. The method is as follows. \n", |
102 | 102 | "\n",
|
103 | 103 | "```python \n",
|
104 |
| - "def train(data, hyperparameters= {'learning_rate': 0.11}, num_cpus=0, num_gpus =1 , **kwargs):\n", |
| 104 | + "def train(data, hyperparameters= {'learning_rate': 0.11}, num_cpus=1, num_gpus =0 , **kwargs):\n", |
105 | 105 | " train_labels = data['train_label']\n",
|
106 | 106 | " train_images = data['train_data']\n",
|
107 | 107 | " test_labels = data['test_label']\n",
|
|
133 | 133 | "outputs": [],
|
134 | 134 | "source": [
|
135 | 135 | "from mnist import train\n",
|
136 |
| - "model = train(data = data, num_cpus=0, num_gpus=1)" |
| 136 | + "model = train(data = data, num_cpus=1, num_gpus=0)" |
137 | 137 | ]
|
138 | 138 | },
|
139 | 139 | {
|
140 | 140 | "cell_type": "markdown",
|
141 | 141 | "metadata": {},
|
142 | 142 | "source": [
|
143 |
| - "If you want to run the training on a cpu or if you are on an instance with cpus only, pass appropriate arguments. \n", |
144 |
| - "\n", |
145 | 143 | "## Set up hosting for the model\n",
|
146 | 144 | "\n",
|
147 | 145 | "### Export the model from mxnet\n",
|
|
0 commit comments