Skip to content

Instantly share code, notes, and snippets.

#!/usr/bin/env python
# https://karpathy.github.io/2015/05/21/rnn-effectiveness/
import numpy as np
def rnn_fwd(x, h_in, Wxh, Whh, Why, bh, by):
h_out = np.tanh(x.dot(Wxh) + h_in.dot(Whh) + bh)
y = h_out.dot(Why) + by
cache = (x, h_in, Wxh, Whh, Why, bh, by, h_out)
@machinaut
machinaut / gan.py
Last active March 18, 2018 02:36
Little GAN
#!/usr/bin/env python
import matplotlib.pyplot as plt
import numpy as np
import tensorflow as tf
from scipy.stats import norm, gaussian_kde
def get_generator(*,
x_size,
@machinaut
machinaut / reptile.py
Last active March 13, 2018 17:50
reptile in tensorflow
#!/usr/bin/env python
import matplotlib.pyplot as plt
import numpy as np
import tensorflow as tf
def get_model(hidden_units=[64, 64],
activation=tf.tanh,
inner_optimizer=tf.train.GradientDescentOptimizer,
@machinaut
machinaut / gravity.py
Created February 9, 2018 19:40
mujoco-py - Change Model Parameters on the Fly
#!/usr/bin/env python
import time
import numpy as np
from mujoco_py import load_model_from_xml, MjSim, MjViewer
XML = '''
<mujoco>
<worldbody>
<geom name='floor' pos='0 0 0' size='5 5 .125' type='plane' condim='3'/>
#!/usr/bin/env python
import RPi.GPIO as GPIO
import time
import subprocess
import glob
import os
import shutil
@machinaut
machinaut / kademlia.py
Created August 14, 2017 17:18
kademlia implementation (work in progress)
#!/usr/bin/env python
# https://pdos.csail.mit.edu/~petar/papers/maymounkov-kademlia-lncs.pdf
import hashlib
import json
import random
import requests
import time
from collections import deque
from concurrent.futures import ThreadPoolExecutor
from http.server import BaseHTTPRequestHandler
@machinaut
machinaut / Dockerfile
Created July 16, 2017 01:34
mujoco-py in fedora
FROM fedora:26
RUN mkdir -p ~/.mujoco
RUN yum install -y make gcc-c++ mesa-libGL-devel mesa-libOSMesa-devel glfw redhat-rpm-config patchelf
RUN dnf install -y python35
WORKDIR /root
RUN python3.5 -m venv env
RUN /bin/bash -c "source env/bin/activate && pip install numpy cython pillow"
@machinaut
machinaut / rotation.py
Last active September 14, 2022 10:23
rotation.py
# rotation.py - rotation methods for GPR
# Many methods borrow heavily or entirely from transforms3d
# eventually some of these may be upstreamed, but credit to transforms3d
# authors for implementing the many of the formulations we use here.
import numpy as np
'''
Rotations
=========
//-----------------------------------//
// This file is part of MuJoCo. //
// Copyright (C) 2016 Roboti LLC. //
//-----------------------------------//
#include "mujoco.h"
#include "stdio.h"
#include "stdlib.h"
#include "string.h"
@machinaut
machinaut / drop_vdso.c
Created April 26, 2017 06:09
drop vdso
#include <elf.h>
#include <linux/auxvec.h>
#include <stdio.h>
#include <sys/syscall.h>
#include <time.h>
void drop_vdso(char *envp[]) {
Elf64_auxv_t *auxv, *ehdr, *last;
while(*envp++ != NULL); // skip the environment vars