Menu
Apache MXNet on AWS
Developer Guide

Step 3: Run an Apache MXNet Code Example

The Deep Learning AMI that you used to launch your EC2 instance also installs Python 2 and Python 3. To test your installation of MXNet, use Python 2 to write some simple MXNet code and run it on the EC2 instance. The code creates a two-dimensional array using the NDArray API, and prints it. For more information about the API, see NDArray API.

You can also create a Jupyter notebook, and write and run the MXNet code in Python. For more information, see Set up a Jupyter Notebook.

Write code to test your installation

  1. Start the Python terminal.

    Copy
    $ python

    In the following steps, >>> represents the Python prompt.

  2. Import MXNet.

    Copy
    >>> import mxnet as mx;
  3. Create a 5X5 matrix, an instance of the NDArray, with elements initialized to 0, and print the array.

    Copy
    >>> mx.ndarray.zeros((5,5)).asnumpy();

    Verify that the result looks as follows:

    array([[ 0.,  0.,  0.,  0.,  0.],
           [ 0.,  0.,  0.,  0.,  0.],
           [ 0.,  0.,  0.,  0.,  0.],
           [ 0.,  0.,  0.,  0.,  0.],
           [ 0.,  0.,  0.,  0.,  0.]], dtype=float32)
  4. Exit the Python terminal.

    Copy
    >>> exit();

Next Step

Step 4: Train a Model