Calculating Multidimensional Arrays
If you learn how to calculate multidimensional arrays using NumPy, you will be able to implement a neural network efficiently. First, we will look at how to use NumPy to calculate multidimensional arrays. Then, we will implement a neural network.
Multidimensional Arrays
Simply put, a multidimensional array is "a set of numbers" arranged in a line, in a rectangle, in three dimensions, or (more generally) in N dimensions, called a multidimensional array. Let's use NumPy to create a multidimensional array. First, we will create a one-dimensional array, as described so far:
>>> import numpy as np >>> A = np.array([1, 2, 3, 4]) >>> print(A) [1 2 3 4] >>> np.ndim(A) 1 >>> A.shape (4,) >>> A.shape[0] 4
As shown here, you can use the np.ndim()
function to obtain the number of dimensions of an array. You can also use the instance variable, shape
, to obtain the shape of the array...