NumPy Any: Understanding np.any()

Posted 2021-10-21

The np.any() function tests whether any element in a NumPy array evaluates to true: The input can have any shape and the data type does not have to be boolean (as long as it’s truthy). If none of the elements evaluate to true, the function returns false: Passing in a value for the axis argument … Read more

NumPy Meshgrid: Understanding np.meshgrid()

Posted 2021-02-09 • Last updated 2021-10-21
numpy meshgrid loss surface

You can create multi-dimensional coordinate arrays using the np.meshgrid() function, which is also available in PyTorch and TensorFlow. But watch out! PyTorch uses different indexing by default so the results might not be the same.

Numpy Pad: Understanding np.pad()

Posted 2021-01-30 • Last updated 2021-10-21
numpy pad reflection

The np.pad() function has a complex, powerful API. But basic usage is very simple and complex usage is achievable! This post shows you how to use NumPy pad and gives a couple examples.

NumPy Norm: Understanding np.linalg.norm()

Posted 2021-01-08 • Last updated 2021-10-15

You can calculate the L1 and L2 norms of a vector or the Frobenius norm of a matrix in NumPy with np.linalg.norm(). This post explains the API and gives a few concrete usage examples.