This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
echo "Installing conda..." | |
# https://waylonwalker.com/install-miniconda/ | |
mkdir -p ~/miniconda3 | |
wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh -O ~/miniconda3/miniconda.sh | |
bash ~/miniconda3/miniconda.sh -b -u -p ~/miniconda3 | |
rm -rf ~/miniconda3/miniconda.sh | |
~/miniconda3/bin/conda init bash | |
# set up pytorch | |
echo "Installing Python dependencies..." |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
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): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# minimal example, using code from: https://sidsite.com/posts/autodiff/ | |
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import math | |
import matplotlib.pyplot as plt | |
import numpy as np | |
np.random.seed(0) | |
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 |