Skip to content

Instantly share code, notes, and snippets.

@hedgefair
hedgefair / tsne-transform.py
Created September 21, 2017 21:24 — forked from MLWave/tsne-transform.py
Embed test points in existing t-sne map
# Author: HJ van Veen <[email protected]>
# Description: Experiment to learn a tSNE transformer for new
# test data with a multi-output GBM
#
# Idea first seen at lvdmaaten.github.io/tsne
# > [...] it is not possible to embed test points in an existing
# > map [...]
# > A potential approach to deal with this would be to train
# > a multivariate regressor to predict the map location from
# > the input data.
from __future__ import print_function
import os
import numpy as np
from keras.layers import RepeatVector
from keras.layers.core import Dropout
from keras.layers.recurrent import LSTM
from keras.models import Sequential
from keras.models import load_model
@hedgefair
hedgefair / russell_3000_2011-06-27.csv
Created September 7, 2017 14:50 — forked from huned/russell_3000_2011-06-27.csv
Ticker symbols for all the companies in the Russell 3000 Index as of 2011-06-27
We can make this file beautiful and searchable if this error is corrected: No commas found in this CSV file in line 0.
A
ACO
AA
ACOM
AAN
ACOR
AAON
ACPW
AAP
ACTG
@hedgefair
hedgefair / Selu_keras.py
Created June 12, 2017 20:40 — forked from thisismohitgupta/Selu_keras.py
Selu activation for keras and tensorflow backend, works better than Relu
import keras.backend as K
from keras.engine import Layer
import tensorflow as tf
class SelU(Layer):
def __init__(self, alpha=1.6732632423543772848170429916717, scale=1.0507009873554804934193349852946, **kwargs):
super(SelU, self).__init__(**kwargs)
self.alpha = K.cast_to_floatx(alpha)
@hedgefair
hedgefair / pythontojulia.md
Created June 6, 2017 00:59 — forked from cuckookernel/pythontojulia.md
Python to Julia Quick translation / conversion reference Guide

A quick and dirty syntax translation / conversion reference guide to ease the transition between Python and Julia. This is not meant as a reference to the language. For that you should read the manual.

Some important differences

  • Arrays in Julia are indexed starting from 1.
  • In Julia classes (i.e. types) don't own methods. Methods are implementations of generic functions and are invoked in a "static style", i.e. instead of Python's str1.rstrip(), we will have rstrip( str1 ), instead of file1.close(), close( file1 ).

Some important similarities.

@hedgefair
hedgefair / roll_ipython_in_aws.md
Created January 20, 2017 18:51 — forked from iamatypeofwalrus/roll_ipython_in_aws.md
Create an iPython HTML Notebook on Amazon's AWS Free Tier from scratch.

What

Roll your own iPython Notebook server with Amazon Web Services (EC2) using their Free Tier.

What are we using? What do you need?

  • An active AWS account. First time sign-ups are eligible for the free tier for a year
  • One Micro Tier EC2 Instance
  • With AWS we will use the stock Ubuntu Server AMI and customize it.
  • Anaconda for Python.
  • Coffee/Beer/Time
@hedgefair
hedgefair / cartpole.py
Created October 2, 2016 14:35 — forked from Smerity/cartpole.py
Script for Cartpole using policy gradient via Chainer, two layer MLP, dropout, and rejection sampling of historical memories
''' Script for Cartpole using policy gradient via Chainer, two layer MLP, dropout, and rejection sampling of historical memories '''
import gym
import numpy as np
import chainer
from chainer import optimizers
from chainer import ChainList, Variable
import chainer.functions as F
@hedgefair
hedgefair / gruln.py
Created July 23, 2016 21:47 — forked from udibr/gruln.py
Keras GRU with Layer Normalization
from keras.layers import GRU, initializations, K
from collections import OrderedDict
class GRULN(GRU):
'''Gated Recurrent Unit with Layer Normalization
Current impelemtation only works with consume_less = 'gpu' which is already
set.
# Arguments
output_dim: dimension of the internal projections and the final output.
@hedgefair
hedgefair / pg-pong.py
Created June 10, 2016 16:38 — forked from karpathy/pg-pong.py
Training a Neural Network ATARI Pong agent with Policy Gradients from raw pixels
""" Trains an agent with (stochastic) Policy Gradients on Pong. Uses OpenAI Gym. """
import numpy as np
import cPickle as pickle
import gym
# hyperparameters
H = 200 # number of hidden layer neurons
batch_size = 10 # every how many episodes to do a param update?
learning_rate = 1e-4
gamma = 0.99 # discount factor for reward