RSSAmplifier

Blog

Read. Hack. Learn. Repeat.

Recent content on Read. Hack. Learn. Repeat.

paepper.comRSS feed ↗59 posts

Latest posts

How I hacked my clock to control my focus

I often get distracted. 
 I obviously don’t like it. 
 So I decided to turn my computer’s clock into a constant reminder to help me focus. 
 Implementation 
 This hack requires: 
 
 Ubuntu with GNOME desktop environment 
 The Panel Date Format extension 
 A simple bash script 
 
 1. Install the Panel Date Format extension 
 # If you don't…

Vibe coding update: voice assistant that types anywhere with screenshot context

Following up on my previous article about Vibe Coding , I’m excited to announce a major enhancement to Vibevoice that takes voice interaction to the next level: AI Command Mode with screenshot context. 
 
 
 Vibevoice in action: now with the option to use an LLM and send your screen as context 
 
 Beyond Simple Dictation: AI Commands with Visual Context 
 While…

Vibe coding with vibevoice: local speech-to-text for any app

The Rise of Vibe Coding 
 Recently, Andrej Karpathy introduced a fascinating concept called “vibe coding” - a new programming paradigm where you “fully give in to the vibes, embrace exponentials, and forget that the code even exists.” This approach has emerged due to the increasing capabilities of Large Language Models (LLMs) and voice-to-text technologies. 
 As…

FlashAttention - optimizing GPU memory for more scalable transformers

FlashAttention 
 Picture this: You’re at an all-you-can-eat buffet, but your plate is the size of a postage stamp. Every time you want more food, you have to sprint back and forth between your table and the buffet, carrying tiny portions. Your food gets cold, you waste energy, and the whole experience becomes inefficient. 
 This is exactly what happens inside AI models during…

LoRA - low rank adaption explained in three minutes

Introduction 
 LoRA ( Low-Rank Adaptation of LLMs ) is a technique that focuses on updating only a small set of low-rank matrices instead of adjusting all the parameters of a deep neural network . This reduces the computational complexity of the training process significantly. 
 LoRA is particularly useful when working with large language models (LLMs) which have a huge amount of…

Understanding the difference between weight decay and L2 regularization

Introduction 
 Machine learning models are powerful tools for solving complex problems, but they can easily become overly complex themselves, leading to overfitting. Regularization techniques help prevent overfitting by imposing constraints on the model’s parameters. One common regularization technique is L2 regularization, also known as weight decay. In this blog post, we’ll…

Intelligent agents guided by LLMs

Update: Trending on Hacker News, follow the discussion here . 
 I’ve built a small library to build agents which are controlled by large language models (LLMs) which is heavily inspired by langchain . 
 You can find that small library with all the code on Github . 
 The goal was to get a better grasp of how such an agent works and understand it all in very few lines of code.…

How to build a chatbot out of your website content

In a previous blog entry , we used langchain to make a Q&A bot out of the content of your website. 
 The Github repository which contains the code of the previous as well as this blog entry can be found here . 
 It was trending on Hacker news on March 22nd and you can check out the disccussion here . 
 This blog posts builds on the previous entry and makes a chatbot which you can…

Build a Q&A bot of your website content with langchain

If you want to learn how to create embeddings of your website and how to use a question answering bot to answer questions which are covered by your website, then you are in the right spot. 
 The Github repository which contains all the code of this blog entry can be found here . 
 It was trending on Hacker news on March 22nd and you can check out the disccussion here . 
 We will…

Interactive visualization of stable diffusion image embeddings

A great site to discover images generated by stable diffusion (or their custom model called aperture) is Lexica.art . 
 Lexica provides an API which can be used to query images matching some keyword / topic. The API returns image URLs, sizes and other things like the prompt used to generate the image and its seed. 
 The goal of this blog post is to visualize the similarity of images from…

Semantic segmentation with prototype-based consistency regularization

Semantic segmentation is a complex task for deep neural networks, especially when limited training data is available. Unlike image classification problems such as Imagenet, semantic segmentation requires a class prediction for every individual pixel rather than just an image-level class. This requires a high level of detail and can be difficult to achieve with limited labeled data. 
 Obtaining…

Everything you need to know about stable diffusion

The goal of this article is to get you up to speed on stable diffusion. You will learn the main use cases , how stable diffusion works , debugging options , how to use it to your advantage and how to extend it . 
 I) Main use cases of stable diffusion 
 There are a lot of options of how to use stable diffusion, but here are the four main use cases: 
 
 Overview of the four main…

Frame decisions as bets to improve decision making

An interesting way to think about making decisions is to consider each decision as a bet with yourself about future versions of your life. 
 Annie Duke who was a professional poker player winning high amounts of price money and big titles wrote a fascinating book called “Thinking in Bets” ( You can buy it here ). 
 I highly recommend reading it as she brings along a lot of fun…

How and why stable diffusion works for text to image generation

Stable diffusion is all the rage in the deep learning community at the moment. It’s trending on Twitter at #stablediffusion and gaining large amounts of attention all over the internet. 
 We’ll take a look into the reasons for all the attention to stable diffusion and more importantly see how it works under the hood by considering the well-written paper “High-resolution image…

Rethinking Depthwise Separable Convolutions in PyTorch

This is a follow-up to my previous post of Depthwise Separable Convolutions in PyTorch . This article is based on the nice CVPR paper titled “Rethinking Depthwise Separable Convolutions:
How Intra-Kernel Correlations Lead to Improved MobileNets” by Haase and Amthor. 
 Previously I took a look at depthwise separable convolutions which are a drop-in replacement for standard…

Creating Pleasant Plots With Seaborn

Creating pleasant plots with seaborn 
 Seaborn is an awesome Python library to create great-looking data plots. It’s a bit higher level than the often used matplotlib and this blog entry serves as a self-reminder about the most frequently used plots for myself. 
 It’s way to specify in a declarative way what you want to plot rather than plot details like markers, colors etc is…

DINO - Emerging properties in self-supervised vision transformers

Today’s paper: Emerging properties in self-supervised vision transformers by Mathilde Caron et al. 
 Let’s get the dinosaur out of the room: the name DINO refers to self- di stillation with no labels. 
 The self-distillation part refers to self-supervised learning in a student-teacher setup as is often seen for distillation. However, the catch is that in contrast to normal…

Rethinking Batch in BatchNorm

Today’s paper: Rethinking ‘Batch’ in BatchNorm by Wu & Johnson 
 
 BatchNorm is a critical building block in modern convolutional neural networks. Its unique property of operating on “batches” instead of individual samples introduces significantly different behaviors from most other operations in deep learning. As a result, it leads to many hidden caveats that…

Hyperparameter tuning on numerai data with PyTorch Lightning and weights & biases

To compare the previously described approach of hyperparameter tuning using fastai and wandb , today we’ll see how to tackle the same approach, but using PyTorch Lightning instead of fastai.
The goal is to have an automated hyperparameter tuning pipeline running on the Numerai data set. 
 What is Numerai? 
 Numerai is a hedge fund which trades stocks in a market neutral fashion.…

Hyperparameter tuning on numerai data with fastai and weights & biases

Today we will try to tackle the Numerai tournament using the fastai deep learning library.
However, as the results likely depend on many different hyperparameters, let’s take advantage of the weights and biases library and their sweeps API.
Sweeps are hyperparameter runs which test out different combinations of your model’s hyperparameters. 
 What is Numerai? 
 Numerai…

P-Diff Learning Classifier with noisy labels based on probability difference distributions

Label noise in digital Pathology 
 In the field of digital pathology and other health related deep learning applications, label noise is an important challenge to consider during training. 
 It’s inherent to the medical fields as the problems are extremely challenging even for trained experts, so there is high intra- as well as inter-observer variability. 
 This blog post dives…

Git config

Git config 
 I like to have a global git config which takes care of my usual git setup like typical commands and abbreviations I use, my username and my email address. 
 It can be helpful to adjust some of this information for a local project, e.g. when you are normally having your regular email address setup, but in one of the local folders you develop for a company you work for and you…

Bash string manipulation

Bash string manipulation 
 When I write bash scripts in my terminal, I often need to manipulate strings. 
 Unfortunately, I often forget how to do this properly in bash, so I thought I’d write a blog article for me to remember better in the future. Hopefully it will be helpful for some of you developers out there as well. 
 String manipulation in bash is not hard, but I find some…

Meta-learning from noisy labels

Label noise introduction 
 Training machine learning models requires a lot of data. Often, it is quite costly to obtain sufficient data for your problem. Sometimes, you might even need domain experts which don’t have much time and are expensive. 
 One option that you can look into is getting cheaper, lower quality data, i.e. have less experienced people annotate data. This usually…

Refactoring machine learning code - namedtuple

Instead of using sometimes confusing indexing in your code, use a namedtuple instead.
It’s backwards compatible, so you can still use the index, but you can make your code much more readable. 
 This is especially helpful when you transform between PIL and numpy based code, where PIL uses a column, row notation while numpy uses a row, column notation. 
 Let’s consider this…

Refactoring machine learning code - einops

Einops is a really great library to improve your machine learning code. It supports Numpy, PyTorch, Tensorflow and many more machine learning libraries.
It helps to give more semantic meaning to your code and can also save you a lot of headaches when transforming data. 
 As a primer let’s look at a typical use-case in machine learning where you have a bunch of data and you want to…

Refactoring machine learning code - comments as code

I find that in the field of data science and machine learning some coding principles that are standard in traditional software engineering sometimes are lacking.
One such principle is to strive to rather specify everything that is possible in code rather than as comments. 
 Why does it make sense to do that? 
 Comments often don’t age well. You write them in the context of the…

Depthwise Separable Convolutions in PyTorch

In many neural network architectures like MobileNets, depthwise separable convolutions are used instead of regular convolutions.
They have been shown to yield similar performance while being much more efficient in terms of using much less parameters and less floating point operations (FLOPs).
Today, we will take a look at the difference of depthwise separable convolutions to standard…

Pyramidal Convolution: Rethinking Convolutional Neural Networks for Visual Recognition

Today’s paper: Pyramidal Convolution by Duta et al. 
 This is the third paper of the new series Deep Learning Papers visualized and it’s about using convolutions in a pyramidal style to capture information of different magnifications from an image.
The authors show how a pyramidal convolution can be constructed and apply it to several problems in the visual…

How to properly manage ssh keys for server access

This article was on the hacker news frontpage. You can find the related discussion here . 
 Every developer needs access to some servers for example to check the application logs. 
 Usually, this is done using public-private key encryption where each developer generates their own public-private key pair.
The public keys of each developer are added to the authorized_keys file on each…

End-to-End object detection with transformers

Today’s paper: End-to-End object detection with transformers by Carion et al. 
 This is the second paper of the new series Deep Learning Papers visualized and it’s about using a transformer approach (the current state of the art in the domain of speech) to the domain of vision.
More specifically, the paper is concerned with object detection and here is the link to the paper of…

Accurate, Large Minibatch SGD: Training ImageNet in 1 Hour

New blog series: Deep Learning Papers visualized 
 This is the first post of a new series I am starting where I explain the content of a paper in a visual picture-based way.
To me, this helps tremendously to better grasp the ideas and remember them and I hope this will be the same for many of you as well. 
 Today’s paper: Accurate, Large Minibatch SGD: Training ImageNet in 1 Hour…

Swift as a viable Python alternative?

Recently Swift for Tensorflow has picked up some steam, so I wanted to explore the Swift programming language a bit. 
 The main advantage over Python for Swift is that Swift is very fast by directly using the LLVM compiler infrastructure.
Python itself relies a lot on C to make code run fast, but if you write Python code you can get very slow code if it’s not optimized. 
…

Eigenvectors and eigenvalues in machine learning

As a data scientist, you are dealing a lot with linear algebra and in particular the multiplication of matrices. Important properties of a matrix are its eigenvalues and corresponding eigenvectors. 
 So let’s explore those a bit to get a better intuition of what they tell you about the transformation. 
 We will just need numpy and a plotting library and create a set of points that…

Parsing JSON data from AWS lambda functions in Python

Lambda functions are a great way to put small workloads into the cloud without needing to care about servers or scalability. 
 They work well with Python and the data format you’ll most likely be using to exchange data is JSON. 
 
 
 I help you listen through the noise in machine learning: 
 
 
 
 This is a very brief post to show how to do this in Python, in…

PyTorch multi-GPU training for faster machine learning results

When you have a big data set and a complicated machine learning problem, chances are that training your model takes a couple of days even on a modern GPU. 
 However, it is well-known that the cycle of having a new idea, implementing it and then verifying it should be as quick as possible.
This is to ensure that you can efficiently test out new ideas. 
 If you need to wait for a whole…

Plot PyTorch tensors with matplotlib

Have you ever tried to plot a PyTorch tensor with matplotlib like: 
 plt . plot(tensor)
 and then received the following error? 
 AttributeError : 'Tensor' object has no attribute 'ndim' 
 You can get around this easily by letting all PyTorch tensors know how to respond to ndim like this: 
 torch . Tensor . ndim = property( lambda self: len(self . shape))
 Basically, this…

Do you know which inputs your neural network likes most?

Recent advances in training deep neural networks have led to a whole bunch of impressive machine learning models which are able to tackle a very diverse range of tasks.
When you are developing such a model, one of the notable downsides is that it is considered a “black-box” approach in the sense that your model learns from data you feed it, but you don’t really know what is…

Shapeshifting PyTorch

An important consideration in machine learning is the shape of your data and your variables.
You are often shifting and transforming data and then combining it.
Thus, it is essential to know how to do this and what shortcuts are available. 
 Let’s start with a tensor with a single dimension: 
 import torch
 test = torch . tensor([ 1 , 2 , 3 ])
 test . shape
…

What are embeddings in machine learning?

Every now and then, you need embeddings when training machine learning models. But what exactly is such an embedding and why do we use it? 
 Basically, an embedding is used when we want to map some representation into another dimensional space. Doesn’t make things much clearer, does it? 
 So, let’s consider an example: we want to train a recommender system on a movie database…

Bash: Keep Script Running - Restart on Crash

When you are prototyping and developing small scripts that you keep running, it might be annoying that they quit when an error occurs.
If you want very basic robustness against these crashes, you can at least use a bash script to automatically restart your script on error. 
 The tool to use here is called until and makes this a breeze. 
 Let’s use a dumb example Python script…

Writing command-line tools in Python: argument parsing

Python is a great language to build command-line tools in as it’s very expressive and concise. 
 You want to have the ability to parse arguments in your scripts as you don’t want to hard-code the relevant variable values to make the tool useful. 
 So how do we go about this in Python? It’s easily done using the argparse module. 
 With argparse , you define the…

Better unit tests in Django using Mommy

Unit testing your models in Django 
 As a good developer, you write unit tests, of course. You will probably even write your tests before implementing your logic in a test-driven approach! 
 However, when developing complex models which have interactions and foreign keys, writing tests can get messy and complicated. 
 Say you want to test a model which has many dependencies to other…

PyTorch GPU inference with Docker and Flask

GPU inference 
 In a previous article, I illustrated how to serve a PyTorch model in a serverless manner on AWS lambda . However, currently AWS lambda and other serverless compute functions usually run on the CPU. But what if you need to serve your machine learning model on the GPU during your inference and the CPU just doesn’t cut it? 
 In this article, I will show you how to use…

How To Unfreeze Vim

Sometimes it happens that Vim freezes / gets stuck / doesn’t react and you might wonder what is going on. 
 Recently, I figured out that this happens for me when I accidentally pressed Ctrl + S . 
 It turns out that this is an old legacy features back from the slow days of computing where ressources were really scarce and you sometimes wanted to freeze the output of one program to…

PyTorch Model in Production as a Serverless REST API

PyTorch is great to quickly prototype your ideas and get up and running with deep learning. Since it is very pythonic, you can simply debug it in PyCharm as you are used to in regular Python. 
 However, when it comes to serving your model in production the question arises: how to do it? 
 There are many possibilities to do so, but in this post, you will learn how to serve it as a lambda…

Graphical Explanation of Neural Networks and Gradients with Python

How does an artificial neuron work? 
 Inspired by neurons of the human brain, an artificial neuron receives several input values. 
 These input values are multiplied with the weights of the neuron which reflects that some input values are activating the neuron (positive weights) while others inhibit the neuron (negative weights). 
 The product values are then summed and together create…

Debugging Tensorflow

Debugging Tensorflow 
 Today, I am going to explore different ways to debug Tensorflow which can be a bit cumbersome at times.
However, there are a few good possibilities that I know of to get more insight into the inner workings of Tensorflow. 
 It’s a little more complicated than regular debugging like say in PyTorch where you can use an IDE like PyCharm and simply set…

Deep Learning on Medical Images With U-Net

Illustration taken from the U-Net paper 
 I recently read an interesting paper titled “U-Net: Convolutional Networks for Biomedical
Image Segmentation” by Olaf Ronneberger, Philipp Fischer, and Thomas Brox which describes how to handle challenges in image segmentation in biomedical settings which I summarize in this blog post. 
 Challenges for medical image segmentation…

Build Your Own Javascript Game in 5 Minutes

Hello Phaser.io (version 3) 
 Phaser is a JavaScript library which makes it super easy for you to build games. It builds on top of WebGL, but if your browser doesn’t support that, falls back to canvas support.
In this quick post, I will show you how to get up and running with your first game in literally 5 minutes (if you take mine as a starter).
Note that I use the new version 3…