Skip to content

Instantly share code, notes, and snippets.

@jcboyd
jcboyd / ubuntu-cuda-caffe.Dockerfile
Created November 9, 2016 17:23
Dockerfile for ubuntu 16.04 + CUDA 8.0 + Caffe for deep learning -- https://hub.docker.com/r/jcboyd/ubuntu-cuda-caffe/
# $ docker run \
# --device /dev/nvidia0:/dev/nvidia0 \
# --device /dev/nvidiactl:/dev/nvidiactl \
# --device /dev/nvidia-uvm:/dev/nvidia-uvm jcboyd/ubuntu-cuda-caffe
# Download base image
FROM ubuntu:16.04
# Set environment variables
ENV PATH "/usr/local/cuda-8.0/bin:$PATH"
@jcboyd
jcboyd / confusion_matrix.png
Last active September 19, 2018 15:02
confusion matrix
confusion_matrix.png
import os
import cStringIO
import requests
import wave
# acquire credentials at https://www.ibm.com/watson/services/text-to-speech/
user_name = ''
password = ''
from __future__ import print_function
from __future__ import division
import io
import random
import numpy as np
from PIL import Image
from skimage.transform import resize
import quantumrandom # https://qrng.anu.edu.au/
@jcboyd
jcboyd / pca.ipynb
Created October 15, 2022 11:01
PCA residual plot
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@jcboyd
jcboyd / metropolis-hastings.ipynb
Created January 15, 2023 15:55
Metropolis-Hastings algorithm
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@jcboyd
jcboyd / eratosthenes.tex
Created January 30, 2024 08:22
Sieve of Eratosthenes with tikz
\documentclass[tikz]{standalone}
\usepackage{tikz}
\begin{document}
\def\primes{2,3,5,7,11,13,17,19,23}
\def\revprimes{23,19,17,13,11,7,5,3,2}
\def\palette{{
"0.00 0.00 1.00",
@jcboyd
jcboyd / subset_sum.py
Created February 10, 2024 06:23
Dynamic programming algorithm for subset sum
"""Two tricks enable an efficient solution:
2. We can solve the problem for the first i numbers in the list, for
i = 1, ..., N
1. The range of possible sums, R is bounded by an efficiently computable
min_sum and max_sum.
The lookup table is thus of dimension N x R. For each subset i = 1, ..., N,
we determine the range of values attainable with that subset, which are
simply all the targets of subset i - 1, plus nums[i] (included), and plus 0
(not included). Thus, we perform only R operation per N subsets.
"""
@jcboyd
jcboyd / harris_visualisation.py
Created February 13, 2024 06:46
Visualisation of Harris detector
import numpy as np
import matplotlib.pyplot as plt
import seaborn as sns
from matplotlib.patches import Circle, Rectangle, FancyArrowPatch
import matplotlib.lines as mlines
from scipy.ndimage import gaussian_filter