## PyTorch Tensor to NumPy Array and Back

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

Skip to content# numpy

## PyTorch Tensor to NumPy Array and Back

2021-03-22## NumPy Where: Understanding np.where()

2021-03-03## NumPy All: Understanding np.all()

2021-02-25## Linear Interpolation in Python: An np.interp() Example

2021-02-15## NumPy Meshgrid: Understanding np.meshgrid()

2021-02-09## Numpy Pad: Understanding np.pad()

2021-01-30## Reshaping Arrays: How the NumPy Reshape Operation Works

2021-01-11## NumPy Norm: Understanding np.linalg.norm()

2021-01-08## Scientific Notation in Python and NumPy

2021-01-04## NumPy Tile: Understanding np.tile()

2021-01-02

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.

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

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

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

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.

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.

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

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.

Using and suppressing scientific notation in Python and NumPy.

The unofficial guide to np.tile() with examples.