ArrayLab Explore arrays. Understand tensors.

An interactive NumPy laboratory

Explore arrays.
Understand tensors.

Type numbers and watch them become a real NumPy array — then reduce along axes, slice, reshape and broadcast, and see what NumPy does. Python runs right in your browser.

  1. 1Type numbers — no Python needed to start.
  2. 2See the ndarray — its grid, axes, shape and dtype.
  3. 3Change something — an axis, an index, a shape — and watch NumPy's answer.
a = shape (2, 3)
Try

Spaces or commas between values · new line = new row · blank line = new 2-D layer (3-D array).

Starting Python… (first visit downloads ≈ 15 MB, then it is cached)

a waiting for NumPy…

a.shape
(2, 3)
a.ndim
2
a.size
6
a.dtype
…
a.itemsize
…
a.nbytes
…

Chapters

  1. 01 Meet the ndarray Type numbers, get a NumPy array, and read its shape, ndim and size.
  2. 02 Shape Rearrange the same elements: reshape, flatten, ravel and transpose.
  3. 03 Axis What axis=0 and axis=1 really mean — and how reductions collapse an axis.
  4. 04 Indexing & Slicing Pick single elements, rows, columns, ranges and masks — and see exactly what you selected.
  5. 05 dtype Every element has the same type. See what conversions do to values and memory.
  6. 06 Broadcasting Combine arrays of different shapes: align from the right, stretch the 1s.
  7. 07 Vectorization Replace Python loops with whole-array operations — same result, far less work.
  8. 08 View vs copy Which operations share memory with the original array — and what happens when you write into them.
  9. 09 Combining arrays Join arrays with concatenate and stack, add an axis with np.newaxis, and cut them apart with split.
  10. 10 NumPy → PyTorch ndarray vs Tensor: converting, similarities and differences. PyTorch
  11. 11 PyTorch Tensor Tensor creation, shape, dtype, numel and device. PyTorch
  12. 12 Autograd requires_grad, the computational graph, backward and gradients. PyTorch
  13. 13 NumPy → pandas A DataFrame is an array with labels: dtype per column, axis, loc vs iloc, alignment. pandas
ArrayLab runs Python and NumPy in your browser with Pyodide. No server, no account — nothing you type leaves your computer. · Source on GitHub