Start the python terminal.
$ python
Run a short MXNet python program to create a 2X3 matrix of ones, multiply each element in the matrix by 2 followed by adding 1. We expect the output to be a 2X3 matrix with all elements being 3.
>>> import mxnet as mx
>>> a = mx.nd.ones((2, 3))
>>> b = a * 2 + 1
>>> b.asnumpy()
array([[ 3., 3., 3.],
[ 3., 3., 3.]], dtype=float32)
This is similar to the previous example, but this time we use mx.gpu(), to set MXNet context to be GPUs.
>>> import mxnet as mx
>>> a = mx.nd.ones((2, 3), mx.gpu())
>>> b = a * 2 + 1
>>> b.asnumpy()
array([[ 3., 3., 3.],
[ 3., 3., 3.]], dtype=float32)
From the MXNet root directory run: python example/image-classification/train_mnist.py --network lenet --gpus 0
to test GPU training.
Activate the virtualenv environment created for MXNet.
$ source ~/mxnet/bin/activate
After activating the environment, you should see the prompt as below.
(mxnet)$
Start the python terminal.
$ python
Run the previous Python example.
Launch a Docker container with mxnet/python
image and run example MXNet python program on the terminal.
$ docker run -it mxnet/python bash # Use sudo if you skip Step 2 in the installation instruction
# Start a python terminal
root@4919c4f58cac:/# python
Run the previous Python example.
Launch a NVIDIA Docker container with mxnet/python:gpu
image and run example MXNet python program on the terminal.
$ nvidia-docker run -it mxnet/python:gpu bash # Use sudo if you skip Step 2 in the installation instruction
# Start a python terminal
root@4919c4f58cac:/# python
Run the previous Python example and run the previous GPU examples.
Login to the cloud instance you launched, with pre-installed MXNet, following the guide by corresponding cloud provider.
Start the python terminal.
$ python
Run the previous Python example, and for GPU instances run the previous GPU example.
Please contribute an example!
Please contribute an example!
Please contribute an example!
Start the pdl2 terminal.
$ pdl2
Run a short MXNet Perl program to create a 2X3 matrix of ones, multiply each element in the matrix by 2 followed by adding 1. We expect the output to be a 2X3 matrix with all elements being 3.
pdl> use AI::MXNet qw(mx)
pdl> $a = mx->nd->ones([2, 3])
pdl> $b = $a * 2 + 1
pdl> print $b->aspdl
[
[3 3 3]
[3 3 3]
]
Run a short MXNet R program to create a 2X3 matrix of ones, multiply each element in the matrix by 2 followed by adding 1. We expect the output to be a 2X3 matrix with all elements being 3.
library(mxnet)
a <- mx.nd.ones(c(2,3), ctx = mx.cpu())
b <- a * 2 + 1
b
You should see the following output:
[,1] [,2] [,3]
[1,] 3 3 3
[2,] 3 3 3
This is similar to the previous example, but this time we use mx.gpu(), to set MXNet context to be GPUs.
library(mxnet)
a <- mx.nd.ones(c(2,3), ctx = mx.gpu())
b <- a * 2 + 1
b
You should see the following output:
[,1] [,2] [,3]
[1,] 3 3 3
[2,] 3 3 3
Run the MXNet-Scala demo project to validate your Maven package installation.
Can you improve this documentation? These fine people already did:
Sheng Zha, Sergey Kolychev & Aaron MarkhamEdit on GitHub
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close