Skip to content

Instantly share code, notes, and snippets.

View SalemAmeen's full-sized avatar

Salem SalemAmeen

View GitHub Profile
@SalemAmeen
SalemAmeen / min-char-rnn.py
Created March 4, 2016 10:18 — forked from karpathy/min-char-rnn.py
Minimal character-level language model with a Vanilla Recurrent Neural Network, in Python/numpy
"""
Minimal character-level Vanilla RNN model. Written by Andrej Karpathy (@karpathy)
BSD License
"""
import numpy as np
# data I/O
data = open('input.txt', 'r').read() # should be simple plain text file
chars = list(set(data))
data_size, vocab_size = len(data), len(chars)
import numpy as np
from matplotlib import pylab as plt
#from mpltools import style # uncomment for prettier plots
#style.use(['ggplot'])
'''
function definitions
'''
# generate all bernoulli rewards ahead of time
def generate_bernoulli_bandit_data(num_samples,K):
@SalemAmeen
SalemAmeen / 2_test_gpu_cuda.sh
Created November 20, 2015 10:52 — forked from graphific/2_test_gpu_cuda.sh
Test script for checking if Cuda and Drivers correctly installed on Ubuntu 14.04
#!/usr/bin/env bash
# Test script for checking if Cuda and Drivers correctly installed on Ubuntu 14.04, by Roelof Pieters (@graphific)
# BSD License
if [ "$(whoami)" == "root" ]; then
echo "running as root, please run as user you want to have stuff installed as"
exit 1
fi
###################################
# Ubuntu 14.04 Install script for:
@SalemAmeen
SalemAmeen / bayes_bandit_empirical_gain_from_incorporating_priors.py
Created November 15, 2015 14:45 — forked from stucchio/bayes_bandit_empirical_gain_from_incorporating_priors.py
Empirical gain from incorporating priors into the Bayesian Bandit
from numpy import *
from scipy.stats import beta
import random
class BetaBandit(object):
def __init__(self, num_options=2, prior=None):
self.trials = zeros(shape=(num_options,), dtype=int)
self.successes = zeros(shape=(num_options,), dtype=int)
self.num_options = num_options
@SalemAmeen
SalemAmeen / MyConfusionMatrix.Lua
Last active August 29, 2015 14:26 — forked from skaae/MyConfusionMatrix.Lua
confusion matrix for torch
--[[ A Confusion Matrix class
Example:
conf = optim.ConfusionMatrix( {'cat','dog','person'} ) -- new matrix
conf:zero() -- reset matrix
for i = 1,N do
conf:add( neuralnet:forward(sample), label ) -- accumulate errors
end
print(conf) -- print matrix
require 'nn'
-- you just need to provide the linear module you want to convert,
-- and the dimensions of the field of view of the linear layer
function convertLinear2Conv1x1(linmodule,in_size)
local s_in = linmodule.weight:size(2)/(in_size[1]*in_size[2])
local s_out = linmodule.weight:size(1)
local convmodule = nn.SpatialConvolutionMM(s_in,s_out,in_size[1],in_size[2],1,1)
convmodule.weight:copy(linmodule.weight)
convmodule.bias:copy(linmodule.bias)
"""
This is a batched LSTM forward and backward pass
"""
import numpy as np
import code
class LSTM:
@staticmethod
def init(input_size, hidden_size, fancy_forget_bias_init = 3):