Skip to content

Instantly share code, notes, and snippets.

View mschauer's full-sized avatar

Moritz Schauer mschauer

View GitHub Profile
@mschauer
mschauer / Adamopt.jl
Created February 16, 2022 20:02 — forked from vankesteren/Adamopt.jl
Julia implementation of Adam optimizer
module Adamopt
# This is a module implementing vanilla Adam (https://arxiv.org/abs/1412.6980).
export Adam, step!
# Struct containing all necessary info
mutable struct Adam
theta::AbstractArray{Float64} # Parameter array
loss::Function # Loss function
grad::Function # Gradient function
using Distributions, Statistics, LinearAlgebra
## simulate sample trajectory
μ = [1.0, 0.0]
Σ = [0.5 0.0
0.0 0.5]
x0 = rand(MultivariateNormal(μ, Σ)) #start point
β = [0.0, 0.0]
@mschauer
mschauer / julia.jl
Created March 12, 2020 14:15 — forked from c42f/Manifest.toml
Julia Fractals via inverse iteration
using Colors
using ColorVectorSpace
using FileIO
using REPL
using ImageTransformations
using ImageView
@inline function inv_julia_map(z, c, n)
ws = (1.0, exp(2/3*pi*im), exp(-2/3*pi*im))
ws[n]*(z - c)^(1/3)
@mschauer
mschauer / JuliaSquared.jl
Last active March 9, 2020 11:28 — forked from zenon/JuliaSquared.jl
Julia^2: Julia sets in Julia, using Interact. I'd like it faster.
using Plots, Interact, Base.Threads, BenchmarkTools
# only called by resize.
function batchify(maxIndex, numBatches)
if mod(maxIndex, numBatches) == 0
n = numBatches
else
n = numBatches - 1
end
batchSize = div(maxIndex, n)
function has_path(g::AbstractGraph, u::Integer, v::Integer; exclude_vertices::AbstractVector=Vector{eltype(g)}())
T = eltype(g)
seen = falses(nv(g))
next = Vector{T}()
push!(next, u)
excludeset = Set(exclude_vertices)
while !isempty(next)
src = shift!(next) #Get first element
src in excludeset && continue
vertexneighbors = neighbors(g, src)
@mschauer
mschauer / pr.md
Last active September 2, 2015 08:49 — forked from piscisaureus/pr.md
Checkout github pull requests locally

Locate the section for your github remote in the .git/config file. It looks like this:

[remote "origin"]
	fetch = +refs/heads/*:refs/remotes/origin/*
	url = git@github.com:joyent/node.git

Now add the line fetch = +refs/pull/*/head:refs/remotes/origin/pr/* to this section. Obviously, change the github url to match your project's URL. It ends up looking like this: