Skip to content

Instantly share code, notes, and snippets.

View dermesser's full-sized avatar
🐢
a bit of time :-)

Lewin Bormann dermesser

🐢
a bit of time :-)
View GitHub Profile
@dermesser
dermesser / vae.jl
Last active September 4, 2022 18:00
Super simple MNIST Variational Autoencoder
using MKL
using BSON
using Distributions, DistributionsAD
using Flux
using Images
using LinearAlgebra
using MLDatasets
@dermesser
dermesser / accum.R
Created July 20, 2022 22:06
Here you will develop "d,p,q,r" functions for a certain distribution family. We'll call the family "accum" for "accumulate." The setting is that of repeatedly rolling a pair of dice. The random variable X is the number of rolls needed to achieve an accumulated total of at least k dots. So for instance the support of X ranges from ceiling(k/12) t…
# P(dots == n) for k dice
dkdice <- function(n, k=2) {
if (k == 1) {
if (n >= 1 && n <= 6) {
return(1/6)
} else {
return(0);
}
} else if (k < 1) {
@dermesser
dermesser / ofdm.jl
Last active August 28, 2022 18:30
OFDM encoding example in Julia. OFDM is using Fourier transforms to achieve higher spectral efficiency when encoding digital data for e.g. optical fiber transmission.
### A Pluto.jl notebook ###
# v0.19.9
using Markdown
using InteractiveUtils
# ╔═╡ 41a2c7d6-f995-11ec-07f9-c7ee6f2063b4
using Plots, FFTW
# ╔═╡ e751caf1-810c-4c74-9dd0-4d749ad04660
@dermesser
dermesser / forecastcompetition.jl
Last active June 2, 2022 00:30
Monte Carlo weather forecasting competition
using Plots
using Distributions
"""Continuous ground truth."""
function generate_ground_truth(rng::Tuple{Integer, Integer}, n=14)
(rand(Int, n) .% (rng[2]-rng[1]+1) .+ rng[1])
end
"""Bernoulli ground truth."""
function generate_ground_truth(prob1::Real, n=14)
@dermesser
dermesser / Gennames.jl
Last active March 20, 2022 08:13
Generate new surnames from a file with common surnames using a totally overkill 825k-weights LSTM network.
using MKL
using CUDA
import Base
import Flux
import BSON
import Zygote # for BSON
import Dates: now
function modelfile()
@dermesser
dermesser / Gendigit.jl
Last active March 20, 2022 08:16
Generate digits using a GAN (Generative Adversarial Network) based on MNIST samples. Runs better on GPU (5x faster). Example outputs and trained model: https://my.hidrive.com/share/3au.-f7a-j
using MKL
using CUDA
using Flux
using Printf
import Base
import BSON
import Zygote
import MLDatasets as MLD
import Dates
@dermesser
dermesser / adaboost.jl
Created March 15, 2022 13:42
Pluto notebook implementing AdaBoost with linear base classifiers
### A Pluto.jl notebook ###
# v0.18.1
using Markdown
using InteractiveUtils
# ╔═╡ f1405f06-5606-11ec-1959-e3943fdb4a2c
begin
import Plots
import Random
@dermesser
dermesser / SVM.jl
Last active March 15, 2022 13:40
Four different implementations of SVMs in Julia (Quadratic optimization of primal/dual problems/gradient descent)
### A Pluto.jl notebook ###
# v0.18.1
using Markdown
using InteractiveUtils
# ╔═╡ 4bdb73f8-a2c2-11ec-078d-27a1269db616
begin
import JuMP as J
import Plots
@dermesser
dermesser / textgen.jl
Last active March 15, 2022 13:41
Generate random text using an LSTM network in Flux/Julia.
using MKL
using CUDA
import Flux
import Plots
import BSON
import Zygote # for BSON
import Dates: now
import Random
import Distributions as D
@dermesser
dermesser / EM.jl
Created March 13, 2022 08:04
Expectation Maximization comboined with k-means clustering for reconstructing 2D Normal distributions including visualization
### A Pluto.jl notebook ###
# v0.18.1
using Markdown
using InteractiveUtils
# ╔═╡ a49da1ae-3f4a-11ec-1504-eb883d8604e2
begin
import Plots
using Distributions