In this post we will discuss a way of representing a state that has exciting connections with how our brain seems to work. First, we’ll briefly look at some foundational ideas (representation and generalisation). Next, we’ll introduce the Successor Representation (SR), which is motivated by finding a representation that generalises across states, and that might be useful in reinforcement learning. … Read More
Using generators in Python to train machine learning models
If you want to train a machine learning model on a large dataset such as ImageNet, especially if you want to use GPUs, you’ll need to think about how you can stay within your GPU or CPU’s memory limits. Generators are a great way of doing this in Python. What is a generator? A generator is a function that behaves … Read More
How to run scripts in the background
When running machine learning experiments, you might want to run multiple scripts simultaneously, hide printouts for a script or just do things in a terminal window while running a Jupyter Notebook in the background. In this post, we will go through how to run scripts in the background, bring them back to the foreground, and check if the scripts are … Read More
Using Bash Scripts to Parallelise Data Preprocessing for Machine Learning Experiments
Parallelising data preprocessing can save you a lot of time. In this post, we’ll go through how to use bash scripts to make parallelising computation easier. The idea is that you split up the data you need to preprocess into different batches, and you run a few batches on each machine. The bash scripts help you loop through batches to … Read More
How Python implements dictionaries
Python Dictionaries: Not even a space-time tradeoff If you could choose to store things that you’d want to look up later in a Python dictionary or in a Python list, which would you choose? It turns out that looking up items in a Python dictionary is much faster than looking up items in a Python list. If you search for … Read More
Numpy Views vs Copies: Avoiding Costly Mistakes
In this post we will talk about the differences between views and copies. It’s really important you’re aware of the difference between the two. Otherwise you might run into problems like accidentally modifying arrays. What are views and copies? With a view, it’s like you are viewing the original (base) array. The view is actually part of the original array even though … Read More
LSTMs for Time Series in PyTorch
I can’t believe how long it took me to get an LSTM to work in PyTorch! There are many ways it can fail. Sometimes you get a network that predicts values way too close to zero. In this post, we’re going to walk through implementing an LSTM for time series prediction in PyTorch. We’re going to use pytorch’s nn module … Read More
Generating Autoregressive data for experiments
In this post, we will go through how to generate autoregressive data in Python, which is useful for debugging models for sequential prediction like recurrent neural networks. When you’re building a machine learning model, it’s often helpful to check that it works on simple problems before moving on to complicated ones. I’ve found this is especially useful for debugging neural … Read More
Machine Learning resource: Chris Albon’s Code Snippets and Flashcards
I was looking for code to implement early stopping in Keras today and came across Chris Albon’s website. You may know Chris as a host of Partially Derivative, a podcast about data science. Chris has posted many snippets of commented recipe-like code to do simple things on his website. These range from ways to preprocess images, text and dates such … Read More
What makes Numpy Arrays Fast: Memory and Strides
How is Numpy so fast? In this post we find out how Numpy’s ndarray is stored and how it is usually manipulated by Numpy functions using strides. Getting to know the ndarray A NumPy ndarray is a N-dimensional array. You can create one like this:
1 |
X = np.array([[0,1,2],[3,4,5]], dtype='int16') |
These arrays are homogenous arrays of fixed-sized items. That is, all the items in … Read More