September 2019
Intermediate to advanced
420 pages
10h 29m
English
Arrays need not be limited to lists. In fact, they can have an arbitrary number of dimensions. In machine learning, we will often deal with at least 2D arrays, where the column index stands for the values of a particular feature and the rows contain the actual feature values.
With NumPy, it is easy to create multidimensional arrays from scratch. Let's say that we want to create an array with three rows and five columns, with all of the elements initialized to zero. If we don't specify a data type, NumPy will default to using floats:
In [23]: arr_2d = np.zeros((3, 5))... arr_2dOut[23]: array([[0., 0., 0., 0., 0.], [0., 0., 0., 0., 0.], [0., 0., 0., 0., 0.]])
As you probably know from your OpenCV days, this ...
Read now
Unlock full access