Validate MXNet
Get Started ›Validate Your MXNet Installation
- Python
- Python with GPU
- Verify GPU training
- Virtualenv
- Docker with CPU
- Docker with GPU
- Cloud
- C++
- Clojure
- Julia
- Perl
- R
- Scala
Python
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)
Python with GPU
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)
Alternative Language Bindings
C++
Please contribute an example!
Clojure
Please contribute an example!
Julia
Please contribute an example!
Perl
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]
]
R
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
R with GPU
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
Scala
Run the MXNet-Scala demo project to validate your Maven package installation.