Skip to content

Instantly share code, notes, and snippets.

View jakelevi1996's full-sized avatar

jakelevi1996

View GitHub Profile
@jakelevi1996
jakelevi1996 / compare_lr_sched.py
Created November 14, 2024 19:36
Compare linear and cosine learning rate schedules
import numpy as np
from jutility import plotting, util, cli, units
t_max = 300
t_max = 100
lr0 = 1e-3
lr1 = 1e-5
lr1 = 0
t = np.arange(t_max)
@jakelevi1996
jakelevi1996 / PPO_loss.png
Last active November 14, 2024 18:32
Plot PPO loss
PPO_loss.png
@jakelevi1996
jakelevi1996 / inspect_module_example.py
Last active October 1, 2024 23:41
Examples of the ways in which `inspect` can be used to inspect functions, classes, and methods defined within a module
import inspect
from jutility import plotting, util
x = [
(name, value)
for name, value in inspect.getmembers(plotting)
if inspect.isfunction(value)
and name[0] != "_"
]
print(*x, sep="\n")
@jakelevi1996
jakelevi1996 / mrovis.py
Last active October 1, 2024 12:37
Visualise Python MRO
""" See https://docs.python.org/3/howto/mro.html """
class _Displayer:
def __init__(self):
self.set_indent("| ")
self.set_sep("+")
self.set_long_sep(" + ")
self._lin_stack: list[str] = []
self._merge_stack: list[list[type]] = []
@jakelevi1996
jakelevi1996 / change_function_signature.py
Last active October 1, 2024 15:04
Change function signature in Python
import inspect
def f1(a1: int, k1: str="v1", k2: str="v2") -> None:
print("f1", a1, k1, k2)
def f2(a2: int) -> int:
print("f2", a2)
return a2 + 1
def f3(a3: int, **kwargs: str) -> None:
@jakelevi1996
jakelevi1996 / plot_bouldering_scores.py
Last active August 7, 2024 09:59
Plot climbing scores
import numpy as np
from jutility import plotting
scores_list = [
[25.0, 25.0, 24.9, 24.7, 99.6, ],
[24.9, 24.9, 25.0, 9.7, 84.5, ],
[24.4, 24.9, 9.8, 24.6, 83.7, ],
[25.0, 24.9, 24.8, 4.9, 79.6, ],
[9.8, 25.0, 9.8, 24.6, 69.2, ],
[9.8, 10.0, 24.5, 24.5, 68.8, ],
@jakelevi1996
jakelevi1996 / make_poly_table.py
Last active March 7, 2024 14:53
Make Latex table of polynomial coefficients
from jutility import util
def main():
p = util.Printer("poly_table", file_ext="tex", print_to_console=False)
b_deg = 5
a_deg = 7
p("\\documentclass{article}")
p("\\usepackage{subcaption}")
@jakelevi1996
jakelevi1996 / Comparing_normalisation_for_weight_initialisation.png
Last active February 23, 2024 12:17
Comparing normalisation for weight initialisation
Comparing_normalisation_for_weight_initialisation.png
@jakelevi1996
jakelevi1996 / Combined_output.png
Last active January 19, 2024 12:11
Compare capture/recapture statistics for different sample sizes and population sizes
Combined_output.png