This file contains hidden or 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 numpy as np | |
np.random.seed(0) | |
def generate_pair(): | |
# make two random numbers x and y | |
# make x first randomly from 1 to 10 | |
x = np.random.randint(1, 11) | |
y = np.random.randint(1, 11) | |
x_y = x + y |
This file contains hidden or 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
track = track4() | |
car = newCar(track) | |
startDisplay(track, car) | |
def control(sd, pastsd): | |
# average these values to be more smooth | |
leftt = sd[0] + pastsd[0]; | |
mid = sd[1] + pastsd[1]; | |
# this bit of assymetry is actually very clever, because | |
# "intuitively" assymetrical things has more information on it |
This file contains hidden or 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 numpy as np | |
import random | |
from queue import PriorityQueue | |
# here is the task | |
# we want to construct a goal number, starting from a template of expression | |
# i.e. (E * E) + E = 11 | |
# we can expand the expression E node further following the grammar | |
# E -> E + E | E * E | -3 | -2 | -1 | 1 | 2 | 3 |
This file contains hidden or 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 numpy as np | |
import random | |
from queue import PriorityQueue | |
# here is the task | |
# we want to construct a goal number, starting from a template of expression | |
# i.e. (E * E) + E = 11 | |
# we can expand the expression E node further following the grammar | |
# E -> E + E | E * E | -3 | -2 | -1 | 1 | 2 | 3 |
This file contains hidden or 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
(declare-sort Person) | |
(declare-fun ancestor (Person Person) Bool) | |
;; anti symmetry | |
(assert (forall ((x Person) (y Person)) | |
(=> (ancestor x y) (not (ancestor y x))))) | |
;; transitivity | |
(assert (forall ((x Person) (y Person) (z Person)) | |
(=> (and (ancestor x y) (ancestor y z)) |
This file contains hidden or 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 numpy as np | |
# open whichever w2v file you want | |
fd = open("glove.6B/glove.6B.50d.txt").readlines() | |
# return a list of keys (words) and the w2v matrix Nxd | |
def to_numpy(lines): | |
keys = [] | |
ary = [] | |
for l in lines: |
This file contains hidden or 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 | |
# there are 10 casinos | |
# each casino_i initially has 0 arms, however | |
# each casino_i is equipted with a slot-machine maker | |
# assume the slot machine maker is Unif(a_i, opt_i) | |
# where a_i < opt_i < 1 | |
# you can take 2 kinds of actions: |
This file contains hidden or 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
def normalise(mat, axis): | |
if axis == 0: | |
row_sums = mat.sum(axis=1) | |
new_matrix = mat / row_sums[:, np.newaxis] | |
return new_matrix | |
if axis == 1: | |
col_sums = mat.sum(axis=0) | |
new_matrix = mat / col_sums[np.newaxis, :] | |
return new_matrix | |
This file contains hidden or 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 numpy as np | |
from numpy import array | |
from scipy.misc import imresize | |
import copy | |
from scipy.ndimage.filters import gaussian_filter | |
import random | |
from keras.datasets import mnist | |
import matplotlib.pyplot as plt |
This file contains hidden or 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
%% | |
%% This is file `lgrind.sty', | |
%% generated with the docstrip utility. | |
%% | |
%% The original source files were: | |
%% | |
%% lgrind.dtx (with options: `package') | |
%% | |
%% LGrind is used to format source code of different programming | |
%% languages for LaTeX. |