This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from itertools import combinations | |
from collections import defaultdict, Counter | |
def to_multiset(word): | |
return frozenset(Counter(word).items()) | |
def find_longer_words(dictionary, words): | |
for num_words in range(2, min(len(words), 10)): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import keyboard | |
import time | |
if __name__ == '__main__': | |
frames = [0] | |
def forward(): | |
global last_frame_index | |
while True: | |
if not is_paused: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import random | |
from math import sqrt, floor | |
""" | |
Guessing game. When playing, the game picks a random value from i to j | |
and each time a guess g is made, g is added to the previous running cost | |
of playing this game. | |
""" | |
cache = {} | |
class Game: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from math import log10, floor | |
def r(num): | |
num_digits = floor(log10(num) + 1) | |
return num//10 + (num % 10)*(10**(num_digits-1)) | |
def does_a_divide_b(a, b): | |
if b % a == 0: | |
return True | |
else: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from sklearn.datasets import make_classification | |
from sklearn.cross_validation import train_test_split | |
from itertools import product | |
import numpy as np | |
import pandas as pd | |
class NeuralNetwork: | |
g = np.vectorize(lambda z: 1 / (1 + np.exp(-z))) | |
log = np.vectorize(lambda x: np.log(x)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
syntax enable | |
colorscheme monokai | |
set number | |
set ruler | |
set swapfile | |
set dir=~/tmp | |
set tabstop=4 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import random | |
import copy | |
def make_exchange_matrix(N=3, seed=2017): | |
'''In this function, we make an exchange matrix | |
for testing purposes by randomly picking exchange | |
rates from the first currency to all the other | |
currencies. ''' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import random | |
import numpy as np | |
#from cvxpy import * | |
def p(M): | |
"""Method to pretty print our matrix. """ | |
for i in range(len(M)): | |
print(' '.join([str(num) for num in M[i]])) | |
def generate_M(N=3, max_touches=2): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import random | |
class Node(): | |
def __init__(self, data=None): | |
self.data = data | |
self.parent = None | |
self.left = None | |
self.right = None | |
self.load = 1 # Assumed to be a leaf when initialized. |
NewerOlder