Skip to content

Instantly share code, notes, and snippets.

echo "Installing conda..."
mkdir -p ~/miniconda3
wget -O ~/miniconda3/
bash ~/miniconda3/ -b -u -p ~/miniconda3
rm -rf ~/miniconda3/
~/miniconda3/bin/conda init bash
# set up pytorch
echo "Installing Python dependencies..."
sradc /
Created October 5, 2022 18:30 — forked from dmmeteo/
SOLID Principles explained in Python with examples.
Single Responsibility Principle
“…You had one job” — Loki to Skurge in Thor: Ragnarok
A class should have only one job.
If a class has more than one responsibility, it becomes coupled.
A change to one responsibility results to modification of the other responsibility.
class Animal:
def __init__(self, name: str):
sradc /
Last active December 10, 2023 09:31
Automatic Differentiation in 26 lines of Python
import math
class Var:
def __init__(self, val: float, local_gradients=()):
self.val = val
self.local_gradients = local_gradients
self.grad = 0
def backward(self, path_value: float = 1):
for child_var, local_gradient in self.local_gradients:
sradc /
Created October 11, 2021 16:43
vectorised autodiff example
# minimal example, using code from:
from collections import defaultdict
import matplotlib.pyplot as plt
import numpy as np
class Variable:
def __init__(self, value, local_gradients=[]):
self.value = value
self.local_gradients = local_gradients
import math
import matplotlib.pyplot as plt
import numpy as np
N = 13
# Taking only the real part of the Fourier transform, then applying the inverse Fourier transform:
reconstructed = np.fft.ifft(np.fft.fft(signal).real).real