Posts

FastAI deeplearning Part 14.1: Convolutions Deep Dive

Image
 In the following post, I summarize the key ideas from the fastAI course while doing a deep dives into Convolutions (in 14.1) and Resnets (in 14.2). To complement the content when needed I use the Deep Learning Book from Ian Goodfellow et al. Let's get started! Kernels and Convolutions In computer vision problems, before the usage of deep learning, one had to encode almost explicitely which features one want the computer to learn, such as verticat edges. For that purpose, a key operation was the convolution, where a kernel (a matrix aimed to search for an edge for example) was multiplied to the original pixel values in order to create the so called feature map. As one can see from the image, the kernel is detecting where significant chages on the pixel values happened to detect the edges. Padding and outputs of convolutions One thing to note is that the output size after applying the kernel will change to a smaller size , and how much that happens, depends on the kernel size, the s

FastAI deeplearning Part 13.2: NLP deep dive, implementing poetry model from scratch

Image
After getting a theoretical understanding of RNNs and LSTMS in the previous post , we review the theoretical foundations of RNNs, its challenges, and contributions from LSTMs, a foundational work for Transformers and Attention models, which can be implemented with  Hugging Face Tutorial .  Although one would probable, and should not as shown is this post, train from scratch RNNs or LSTMs if the goal is to reach close to the state of the art quality results, understanding the foundations and innovations that has been implemented from a shallow RNN to a LSTM with regularization and dropout make the understanding of attention models architecture easier. In this post we try to implement from scratch a poetry model after learning from all the bibliography of the great spanish poet Garcia Lorca, killed by the fascists after the civil war. He is without any doubt, one of the most remarkable poets in spanish history and the XX century, this is my humble homenage to him. First part - loading th

FastAI deeplearning Part 13.1: NLP deep dive, review of RNNs theory

Image
Due to the complexity of RNNs and my impression that the fastai did no cover sufficient formalities (which is normal in a single notebook), I will start with the chapter on RNNs and LSTMs from the book Deep Learning (Ian Godfellow et al) to consolidate the concepts before we jump into the code and case study. Brief theory on RNNs ( source book ) Recurrent neural networks are particularly useful for sequence data, such as text or in general any time series data. One of the first ideas that allow the use of deep and large recurrent neural networks is the fact that parameters are shared across several time steps, allowing for generalization, independent of the exact position of the observation. Our computational graph (set of computations) will include this time cycles, where the present value is going to affect what will be expected as a realization in the future. More formally: s(t) = f(s(t-1), theta) = f(f(s(t-2);theta);theta) ... (1) This can be unfold for many periods creating the c

FastAI Deep Learning Journey Part 12: MidLevel API applied to Siamese Networks - Whale tracking application

Image
Data Scientists, particularly strong coders, do not like to leverage high level apis without being able to know how to customize the framework for their specific applications. When one see that fastai is able to perform so many steps including data loaders, shuffling, augmentations, transfer learning... in a few lines of code, one is both amazed and terrified. How do I know what is going on under the hood?  If you are the ones like me willing to understand what's going on without going line by line of the source code, you are fine with the documentation and tutorials. If you are willing to be able to debug every single line of code, or need to customize fastai for your problem, do not worry, the mid and low api is for you.  In this post, I will show you how to create your own transforms, pipeline, tensors, data loaders and learners for both text and computer vision problems. To make things more spicy and real, I show how fastai can be use to build siamese networks with much less ef

FastAI Deep Learning Journey Part 11: Text embeddings for almost any downstream task, or universal language fine tuning!

Image
  Natural language processing is booming with thousands of applications with a formidable level of accuracy . In this post we will show how fastai ensures that your language model (and its text embeddings) are sufficiently fine tuned for your downstream task, without the need to use supervised learning. This is going to be more computationally heavy than usual, so when running the nlp repo , make sure you have a GPU and something else to do the couple of hours... let's get started! Univsersal Language Model Fine-tuning, the paper Transfer learning on computer vision is well stablished, almost anyone starts now with a pretrained model from imagenet (resnet 18, 34...), and as we have seen in our previous posts, we only have to fine tune the last layers of the network to get state of the art results fine tuning in computer vision .  Fine tunning in NLP is less known, and most either train a relatively mediocre model from scratch, due to corpora and computing limitations, or stay to a