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)
// 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 / 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,))
#!/usr/bin/env python
"""Example of building a model to solve an XOR problem in Keras."""
import keras
import numpy as np
# XOR data.
x = np.array([
[0, 1],
[1, 0],
@codekansas
codekansas / theano_two_layer.py
Created April 12, 2017 18:34
Two layer neural network in Theano.
import theano
import theano.tensor as T
import numpy as np
X = theano.shared(value=np.asarray([[1, 0], [0, 0], [0, 1], [1, 1]]), name='X')
y = theano.shared(value=np.asarray([[1], [0], [1], [0]]), name='y')
rng = np.random.RandomState(1234)
LEARNING_RATE = 0.01
@codekansas
codekansas / factors.scm
Created September 18, 2017 19:52
Program for finding all the factors of a number in Scheme.
; Finds all factors of a number in O(sqrt n) time.
(define (factors n)
(define (@factors n i a)
(cond ((= (modulo n i) 0) (@factors (quotient n i) i (cons i a)))
((>= (* i i) n) (if (= 1 n) a (cons n a)))
(else (@factors n (+ i 1) a))))
(@factors n 2 `()))
; Multiples all the elements in a list.
(define (mult l)
@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]
#!/usr/bin/env python
"""The training script for the DANN model."""
from __future__ import division
from __future__ import print_function
import csv
import os
import itertools
import sys