Skip to content

Instantly share code, notes, and snippets.

View codekansas's full-sized avatar
🏠
Working from home

Ben Bolte codekansas

🏠
Working from home
View GitHub Profile
@codekansas
codekansas / wireworld.py
Last active July 7, 2016 09:20
My implementation of Wireworld in Python
from __future__ import print_function
from time import sleep
import os
type_to_rep = {
'empty': '.',
'head': 'H',
'tail': 'T',
'conductor': '=',
from __future__ import print_function
import theano
import theano.tensor as T
import numpy as np
import time
X = theano.shared(value=np.asarray([[0, 1], [1, 0], [0, 0], [1, 1]]), name='X')
y = theano.shared(value=np.asarray([[0], [0], [1], [1]]), name='y')
rng = np.random.RandomState(1234)
@codekansas
codekansas / keras_gensim_embeddings.py
Last active July 23, 2018 09:17
Using Word2Vec embeddings in Keras models
from __future__ import print_function
import json
import os
import numpy as np
from gensim.models import Word2Vec
from gensim.utils import simple_preprocess
from keras.engine import Input
from keras.layers import Embedding, merge
class FastScanner {
BufferedReader br;
StringTokenizer st;
public FastScanner() {
br = new BufferedReader(new InputStreamReader(System.in));
}
String next() {
while (st == null || !st.hasMoreElements()) {
// reference: http://codeforces.com/contest/697/problem/C
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;
public class Codeforces697ProblemC {
public static void main(String... args) {
Scanner s = new Scanner(System.in);
@codekansas
codekansas / predictions.txt
Created August 5, 2016 06:48
Predictions after training with the Attention RNN model
[>....................]how compare home insurance
Predicted: ([ 0.39381921])in order to calculate your annual premium for home insurance it be necessary answer some basic question about the risk and obtain a quote basic characteristic of the home will include the year build , square footage , type of roof , foundation type , number of bathroom , style of home , prior claim and identify information of the owner you may obtain a quote and buy home insurance online use an online link in multiple state ; it may be use by escrow / closing professional , mortgage professional , real estate agent directly consumer an exemplary online experience for all WEBSITELINK
Expected: ([ 0.38000157])start by talk to your Insurance Professional it be important not only compare coverage offering and policy extension and limitation , but also the company that be offer this protection proposal and suggest coverage shall be base upon the result of a careful Reconstruction Analysis which will determine the amount of recommend covera
@codekansas
codekansas / ballpark.py
Last active January 16, 2018 10:56
Adding noise to gradients as a regularizer
from keras.optimizers import SGD, Adagrad, RMSprop, Adadelta, Adam, Adamax
import keras.backend as K
DEFAULT_NOISE = 0.05
def ballpark_gradient(gradient, noise):
return [g * K.random_normal(shape=K.shape(g), mean=1.0, std=noise) for g in gradient]
@codekansas
codekansas / freeway.py
Created August 13, 2016 01:26
More general version of the Highway Network
from keras.engine import InputSpec
from keras.layers import Dense
from keras.layers.wrappers import Wrapper, TimeDistributed
class Freeway(Wrapper):
def __init__(self, layer, gate=None, **kwargs):
self.supports_masking = True
self.gate = gate
super(Freeway, self).__init__(layer, **kwargs)
@codekansas
codekansas / keras-xor.py
Created September 11, 2016 06:18
Two-layer XOR in Keras
from __future__ import print_function
import numpy as np
from keras.engine import Input, Model
from keras.layers import Dense
X = np.asarray([[0, 1], [1, 0], [0, 0], [1, 1]])
y = np.asarray([[0], [0], [1], [1]])
input = Input(shape=(2,))
@codekansas
codekansas / .vimrc
Last active May 17, 2018 00:07
vimrc file that i like to use
execute pathogen#infect()
colorscheme badwolf
" turns of syntax highlighting
syntax enable
" use spaces not tabs
set tabstop=8 softtabstop=0 expandtab shiftwidth=2 smarttab
" show line numbers