NumPy Meshgrid: Understanding np.meshgrid()

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

SageMaker Studio Quick Start

Ben Cook • Posted 2021-02-08 • Last updated 2021-10-21
sagemaker studio launcher

A step-by-step quick start guide for SageMaker Studio. Start a Studio session, launch a notebook on a GPU instance and run object detection inference with a detectron2 pre-trained model.

PyTorch One Hot Encoding

Ben Cook • Posted 2021-02-02 • Last updated 2021-12-13

PyTorch has a one_hot() function for converting class indices to one-hot encoded targets.

Numpy Pad: Understanding np.pad()

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

The PyTorch Softmax Function

Ben Cook • Posted 2021-01-29 • Last updated 2021-10-14

You can use the top-level torch.softmax() function from PyTorch for your softmax activation needs.

Iterating Over Rows in Pandas

Ben Cook • Posted 2021-01-29 • Last updated 2021-10-15

When you absolutely have to iterate over rows in a Pandas DataFrame, use the .itertuples() method.

Installing Packages in a Jupyter Notebook

Ben Cook • Posted 2021-01-22 • Last updated 2021-10-15

This post describes a trick for installing/upgrading Python packages in a Jupyter notebook. It’s useful for scratch code, but don’t do this when you need reproducible code.