Skip to content

Instantly share code, notes, and snippets.

@thomasdullien
thomasdullien / leaky_relu_polytopes.py
Created April 4, 2025 06:28
Leaky ReLU MLP training dynamics visualisation PyTorch code
import os
import imageio
import torch
import torch.nn as nn
import torch.optim as optim
import numpy as np
import math
import cv2
from torch.utils.data import DataLoader, TensorDataset
import matplotlib.pyplot as plt
@thomasdullien
thomasdullien / relu_viz.py
Created July 4, 2024 11:58
Visualising creases in a relu network.
from PIL import Image, ImageOps, ImageDraw
import numpy as np
import pandas as pd
import os, sys
import logging
logging.basicConfig(
format='%(asctime)s %(levelname)-8s %(message)s',
level=logging.INFO,
datefmt='%Y-%m-%d %H:%M:%S')
@thomasdullien
thomasdullien / relu_viz.py
Created June 27, 2024 14:09
a NN visualization experiment
from PIL import Image, ImageOps, ImageDraw
import numpy as np
import pandas as pd
import os, sys
#import ace_tools as tools
# Function to load an image from a file
def load_image(file_path):
return Image.open(file_path)
@thomasdullien
thomasdullien / Dockerfile
Created August 25, 2021 14:55
Source code for a container that creates a large directory tree
FROM ubuntu:bionic
RUN chmod 777 /tmp
RUN apt-get update && apt-get -y upgrade
RUN apt-get install -y git wget cmake sudo gcc-7 g++-7 python3-pip zlib1g-dev g++
RUN mkdir /code
COPY ./main.cpp /code
RUN g++ /code/main.cpp -o /code/a.out
RUN chmod +x /code/a.out
@thomasdullien
thomasdullien / fs.go
Created August 25, 2021 14:35
GetDirUsage from fs.go doing recursive directory walks
func GetDirUsage(dir string) (UsageInfo, error) {
var usage UsageInfo
if dir == "" {
return usage, fmt.Errorf("invalid directory")
}
rootInfo, err := os.Stat(dir)
if err != nil {
return usage, fmt.Errorf("could not stat %q to get inode usage: %v", dir, err)
DIRECTORIES="main contrib non-free restricted universe multiverse"
UBUNTU="http://mirror.hetzner.de/ubuntu/packages/pool/ http://ddebs.ubuntu.com/pool/";
DEBIAN="http://mirror.hetzner.de/debian/packages/pool/ http://debug.mirrors.debian.org/debian-debug/pool/"
UBUNTU_DSC="http://archive.ubuntu.com/ubuntu/pool/"
DEBIAN_DSC="http://ftp.debian.org/debian/pool/"
if [[ $# -eq 0 ]]
then
echo "Choose 'all', 'debian', or 'ubuntu' as first argument."
exit 1
@thomasdullien
thomasdullien / mirror_upstream_repo.sh
Created June 19, 2020 15:33
A small shell script to mirror upstream package repositories
DIRECTORIES="main contrib non-free restricted universe multiverse"
UBUNTU="http://mirror.hetzner.de/ubuntu/packages/pool/ http://ddebs.ubuntu.com/pool/";
DEBIAN="http://mirror.hetzner.de/debian/packages/pool/ http://debug.mirrors.debian.org/debian-debug/pool/"
if [[ $# -eq 0 ]]
then
echo "Choose 'all', 'debian', or 'ubuntu' as first argument."
exit 1
fi
@thomasdullien
thomasdullien / index.html
Last active April 29, 2019 16:17
D3 Diagram to illustrate savings.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Minimal D3 Example</title>
<script src="http://d3js.org/d3.v3.min.js" charset="utf-8"></script>
<style>
:root {
--savings-color: #A9C3D0F0;
@thomasdullien
thomasdullien / savings_chart.html
Created April 29, 2019 14:02
attempting to visualize cost savings
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Minimal D3 Example</title>
<script src="http://d3js.org/d3.v3.min.js" charset="utf-8"></script>
<style>
.service_bar_pre {
fill: steelblue;
stroke-width: 3;
@thomasdullien
thomasdullien / inception_annoy.py
Created June 11, 2017 21:06
Inception for feature extraction, ANNoy for nearest-neighbor search
"""
Simple, hacked-up image similarity search using Tensorflow + the inception
CNN as feature extractor and ANNoy for nearest neighbor search.
Requires Tensorflow and ANNoy.
Based on gist code under
https://gist.github.com/david90/e98e1c41a0ebc580e5a9ce25ff6a972d
"""
from annoy import AnnoyIndex