Skip to content

Instantly share code, notes, and snippets.

View gabrieldernbach's full-sized avatar

gabrieldernbach gabrieldernbach

View GitHub Profile
@gabrieldernbach
gabrieldernbach / ml_code_golf.py
Last active June 6, 2022 17:40
Solving mnist, fast and short
from torchvision.datasets import MNIST
import numpy as np
def data(train):
mnist = MNIST(root='.', download=True, train=train)
X = mnist.data.numpy().reshape(-1, 784) / 255
y = mnist.targets.numpy()
return X, y
import numpy as np
from scipy.stats import chi2_contingency
# example data taken from
# https://en.wikipedia.org/wiki/Chi-squared_test#Example_chi-squared_test_for_categorical_data
X = np.array([
[90, 60, 104, 95],
[30, 50, 51, 20],
[30, 40, 45, 35],
])
@gabrieldernbach
gabrieldernbach / continous_sync.sh
Last active May 6, 2021 15:57
sync local folder with remote
fswatch ~/repo/ -o | xargs -I {} rsync -avzhe ssh ~/repo/ server:/home/user/repo/ --delete --exclude "venv/*"
@gabrieldernbach
gabrieldernbach / profiler.py
Created December 14, 2020 14:52
Profiler
import cProfile
import pstats
import io
def profile(file_path=None, breakpoint_after_call=False):
"""decorator for runtime profiling of functions or class methods
prints the profiling statistics sorted by
cumulative time,
total time,