I love fancy machine learning algorithms as much as anyone. But sometimes, you just need to count things. And Python’s built-in data structures make this really easy. Let’s say we have a list of strings: With a list like this, you might care about a few different counts. What’s the … Read More
The PyTorch sigmoid function is an element-wise operation that squishes any real number into a range between 0 and 1. This is a very common activation function to use as the last layer of binary classifiers (including logistic regression) because it lets you treat model predictions like probabilities that their … Read More
TorchVision, a PyTorch computer vision package, has a great API for image pre-processing in its torchvision.transforms module. This post gives some basic usage examples, describes the API and shows you how to create and use custom image transforms.
The NumPy where function is like a vectorized switch that you can use to combine two arrays.
You can find the mode of an empirical continuous distribution by plotting the histogram and looking for the maximum bin.
The np.all() function tests whether all elements in a NumPy array evaluate to true.
A simple NumPy implementation of the binary cross entropy loss function and some intuition about why it works.
Pandas provides a .query() method on DataFrame’s with a convenient string syntax for filtering DataFrames. This post describes the method and gives simple usage examples.