NumPy - Python Library for Matrix operations

This section provides a tutorial example on how to install Python 3 NumPy library on macOS computers. NumPy is widely used by Python users for matrix operations required in neural network models.

What Is NumPy? NumPy is an open-source Python library for matrix operations developed initially by Travis Oliphant and now maintained by the NumPy community.

If you want to build neural network models in Python, you should install NumPy and get familiar with its functionalities by following this tutorial. This is because neural network models require lots of matrix operations, which are provided in NumPy.

1. Make sure you have python 3 installed by running the "python --version" command in a terminal window:

herong$ python --version

Python 3.8.0

2. Install NumPy library using the "pip" (Package Installer for Python) command:

herong$ sudo pip install numpy

Collecting numpy
  Downloading https://files.pythonhosted.org/packages/...
Installing collected packages: numpy
Successfully installed numpy-1.19.0

3. Verify NumPy installation by importing "numpy" package, retrieving its version string, and creating a 3x4 matrix of random numbers:

herong$ python
Python 3.8.0 (v3.8.0:fa919fdf25, Oct 14 2019, 10:23:27)

>>> import numpy as np

>>> np.v2.14
'1.19.0'

>>> np.random.rand(3,4)
array([[0.98825753, 0.73001974, 0.01652119, 0.12592153],
     [0.44776361, 0.36145535, 0.380565  , 0.32035704],
     [0.61031541, 0.5521491 , 0.70684916, 0.05019113]])

Cool! You have NumPy library ready on your Python environment for matrix operations.

For more readings on NumPy, visit NumPy documentation Website at https://numpy.org/doc/.

Table of Contents

 About This Book

 Running Python Code Online

 Python on macOS Computers

 Python on Linux Computers

 Built-in Data Types

 Variables, Operations and Expressions

 Statements - Execution Units

 Function Statement and Function Call

 Iterators, Generators and List Comprehensions

 Classes and Instances

 Modules and Module Files

 Packages and Package Directories

 "sys" and "os" Modules

 "pathlib" - Object-Oriented Filesystem Paths

 "pip" - Package Installer for Python

SciPy.org - Python Libraries for Science

NumPy - Python Library for Matrix operations

 SciPy - Python Library for Mathematical Functions

 pandas - Data Analysis and Manipulation

 Anaconda - Python Environment Manager

 Jupyter Notebook and JupyterLab

 References

 Full Version in PDF/EPUB