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 numpy as np | |
import matplotlib.pyplot as plt | |
BASE_LR = 1e-7 | |
EPOCHS = 500 | |
TRIALS = 3 | |
class LRscanner: |
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
class LinearRegression: | |
def __init__(self, order): | |
self.W = np.random.randn((order+1)) | |
def fit(self, X, Y, alpha=1e-5, epochs=1000): | |
X = np.vstack((X, np.ones_like(X))).T | |
Y = Y.T | |
for _ in range(epochs): |
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 torch | |
import torchvision | |
import torchvision.transforms as transforms | |
import torch.nn as nn | |
import torch.optim as optim | |
import torch.nn.functional as F | |
from tqdm import tqdm | |
import argparse | |
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
# logging_example.py | |
""" | |
With the logging module imported, you can use something called a “logger” to log messages that you want to see. | |
By default, there are 5 standard levels indicating the severity of events. | |
Each has a corresponding method that can be used to log events at that level of severity. | |
The defined levels, in order of increasing severity, are the following: | |
- DEBUG | |
- INFO | |
- WARNING | |
- ERROR |
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 numpy as np | |
from scipy.stats import norm, invgamma | |
# The barrel of apples | |
# The average apples is between 70-100 g | |
BARREL = np.random.normal(loc=85, scale=20, size=100) | |
# Grid | |
WEIGHT_GUESSES = np.linspace(1, 200, 100) | |
ERROR_GUESSES = np.linspace(.1, 50, 100) |
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 numpy as onp | |
from scipy.optimize import minimize | |
from scipy.stats import gaussian_kde | |
import matplotlib.pyplot as plt | |
import jax.numpy as np | |
from jax import random, lax | |
import numpyro | |
import numpyro.distributions as dist | |
from numpyro.infer import MCMC, NUTS |