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 2018/10/22 23:33:37 UTC

[GitHub] thomelane commented on a change in pull request #12918: Fix adversary example generation

thomelane commented on a change in pull request #12918: Fix adversary example generation
URL: https://github.com/apache/incubator-mxnet/pull/12918#discussion_r227170725
 
 

 ##########
 File path: example/adversary/adversary_generation.ipynb
 ##########
 @@ -28,290 +27,312 @@
     "import matplotlib.pyplot as plt\n",
     "import matplotlib.cm as cm\n",
     "\n",
-    "from mxnet.test_utils import get_mnist_iterator"
+    "from mxnet import gluon"
    ]
   },
   {
    "cell_type": "markdown",
    "metadata": {},
    "source": [
-    "Build Network\n",
-    "\n",
-    "note: in this network, we will calculate softmax, gradient in numpy"
+    "Build simple CNN network for solving the MNIST dataset digit recognition task"
    ]
   },
   {
    "cell_type": "code",
-   "execution_count": null,
+   "execution_count": 17,
    "metadata": {
     "collapsed": true
    },
    "outputs": [],
    "source": [
-    "dev = mx.cpu()\n",
-    "batch_size = 100\n",
-    "train_iter, val_iter = get_mnist_iterator(batch_size=batch_size, input_shape = (1,28,28))"
+    "ctx = mx.gpu() if len(mx.test_utils.list_gpus()) else mx.cpu()\n",
 
 Review comment:
   Can you use something like this instead?
   
   ```
   # Use GPU if available
   try:
       mx.test_utils.list_gpus(); ctx = mx.gpu()
   except:
       ctx = mx.cpu()
   batch_size = 128
   ```
   
   Otherwise it throws an uncaught exception on CPU only machines.

----------------------------------------------------------------
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