## NumPy Any: Understanding np.any()

Ben Cook • 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 … Read more

## How the NumPy append operation works

Ben Cook • Posted 2021-10-06 • Last updated 2021-10-15

Understanding the np.append() operation and when you might want to use it.

## PyTorch Tensor to NumPy Array and Back

Ben Cook • Posted 2021-03-22 • Last updated 2021-10-14

You can easily convert a NumPy array to a PyTorch tensor and a PyTorch tensor to a NumPy array. This post explains how it works.

## NumPy Where: Understanding np.where()

Ben Cook • Posted 2021-03-03 • Last updated 2021-10-19

The NumPy where function is like a vectorized switch that you can use to combine two arrays.

## NumPy All: Understanding np.all()

Ben Cook • Posted 2021-02-25 • Last updated 2021-10-21

The np.all() function tests whether all elements in a NumPy array evaluate to true.

## Linear Interpolation in Python: An np.interp() Example

Ben Cook • Posted 2021-02-15 • Last updated 2021-10-21

It’s easy to linearly interpolate a 1-dimensional set of points in Python using the np.interp() function from NumPy.

## NumPy Meshgrid: Understanding np.meshgrid()

Ben Cook • Posted 2021-02-09 • Last updated 2021-10-21

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.

Ben Cook • Posted 2021-01-30 • Last updated 2021-10-21

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.

## Reshaping Arrays: How the NumPy Reshape Operation Works

Ben Cook • Posted 2021-01-11 • Last updated 2021-10-21

This post explains how the NumPy reshape operation works, how to use it and gotchas to watch out for.

## NumPy Norm: Understanding np.linalg.norm()

Ben Cook • 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.