Skip to content

Instantly share code, notes, and snippets.

View ririw's full-sized avatar

Richard Weiss ririw

  • McKinsey and Company / Quantumblack
  • Sydney
View GitHub Profile
@ririw
ririw / ztp.py
Last active February 15, 2022 20:47
PYMC3 Zero truncated poisson distribution
import pymc3 as pm
from pymc3.distributions.dist_math import bound, logpow, factln
from pymc3.distributions import draw_values, generate_samples
import theano.tensor as tt
import numpy as np
import scipy.stats.distributions
class ZTP(pm.Discrete):
def __init__(self, mu, *args, **kwargs):
super().__init__(*args, **kwargs)
@ririw
ririw / RWA.py
Created April 16, 2017 10:22
Recurrent Weighted Average RNN in pytorch
# An implementation of "Machine Learning on Sequential Data Using a Recurrent Weighted Average" using pytorch
# https://arxiv.org/pdf/1703.01253.pdf
#
#
# This is a RNN (recurrent neural network) type that uses a weighted average of values seen in the past, rather
# than a separate running state.
#
# Check the test code at the bottom for an example of usage, where you can compare it's performance
# against LSTM and GRU, at a classification task from the paper. It handily beats both the LSTM and
# GRU :)
@ririw
ririw / install-gpu.sh
Last active December 26, 2017 00:28
Quick script to set up a GPU env on my desktop machine
# Thanks Fast.AI
# Based on their apache-2.0 licensed script
# https://github.com/fastai/courses/blob/master/setup/install-gpu.sh
#
set -e
# This script is designed to work with ubuntu 16.04 LTS
# ensure system is updated and has basic build tools
sudo apt-get update
sudo apt-get --assume-yes upgrade
@ririw
ririw / main.cpp
Created October 9, 2017 03:03
Rebecca code
#include "Arduino.h"
#include <Servo.h>
Servo myservo;
void setup()
{
myservo.attach(0);
Serial.begin(9600);
}
void loop()
@ririw
ririw / repeater.py
Last active June 16, 2016 07:00
A repeat layer for lasagne
## THIS IS WRONG, it'll return the wrong shape. I'll need
## to tweak it to make it work
#class Repeat(lasagne.layers.Layer):
# def __init__(self, incoming, n, **kwargs):
# super(Repeat, self).__init__(incoming, **kwargs)
# self.n = n
#
# def get_output_shape_for(self, input_shape):
# return tuple([self.n] + list(input_shape))
#
@ririw
ririw / Compilation and running
Last active January 1, 2016 21:59
New version of reader code
ghc -O2 -rtsopts -threaded -prof -fprof-auto -fforce-recomp reader.hs
time ./reader +RTS -K1G -sstderr -pa -A3M
@ririw
ririw / Compilation & running
Last active January 1, 2016 21:39
Space inefficient program
ghc -O2 -rtsopts -threaded -prof -fprof-auto -fforce-recomp reader.hs
time ./reader +RTS -K1G -sstderr -pa -A3M
@ririw
ririw / example.py
Created December 3, 2015 03:55
dave's thing
def new_folder(folder_name, content_type, parentID, key=None, read_only=False, allow_children=True):
if key is None:
key = folder_name
interface Functor {
fmap: (any) => any;
}
interface Monad extends Functor {
bind: (any) => Monad;
}
interface Maybe extends Monad {
}