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 tensorflow.examples.tutorials.mnist import input_data | |
mnist = input_data.read_data_sets('MNIST_data', one_hot=True) | |
def softmax(logits): | |
e = np.exp(logits) | |
return e / np.expand_dims(e.sum(axis=1), axis=1) |
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 time | |
inv = 0 | |
def mergesort(arr): | |
global inv | |
if len(arr) <= 1: | |
return arr | |
else: |
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
counts = 0 | |
def quicksort(arr): | |
global counts | |
if len(arr) >= 1: | |
counts += len(arr)-1 | |
if len(arr) <= 1: | |
return arr | |
else: |
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 time | |
import random | |
import copy | |
# j4f | |
def runtime(func, args): | |
now = time.time() | |
func(args) | |
return time.time() - now |
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 time | |
from collections import deque | |
import sys | |
sys.setrecursionlimit(10000) | |
class Node(object): | |
def __init__(self, name): | |
self.name = name | |
self.explored = False |
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 matplotlib.pyplot as plt | |
from tensorflow.examples.tutorials.mnist import input_data | |
def sample_vector(v, w, b, bernoulli=True): | |
h = 1 / (1 + np.exp(-(v.dot(w) + b))) | |
if bernoulli: | |
h = np.random.binomial(1, h) | |
return h |
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
# Sometimes it works, sometimes it doesn't | |
import numpy as np | |
import gym | |
class Net(object): | |
def __init__(self, input, output): | |
# W = 0.01 * np.random.randn(input, output) | |
# b = np.zeros([1, output]) # Random initialization | |
W = np.array([[-0.60944746, 0.45539405], |
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 | |
def sigmoid(v): | |
return 1 / (1 + np.exp(-v)) | |
def one_hot(x): | |
N = x.size | |
D = x.max() + 1 |
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
{ | |
"package": { | |
"version": "3.1", | |
"division": [ | |
{ | |
"alias": "tx2_64bit", | |
"selected": "1", | |
"name": "Jetson TX2" | |
}, | |
{ |
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
from fractions import Fraction | |
import numpy as np | |
def print_matrix(matrix): | |
def tostr(i): | |
return str(i) if i.denominator == 1 else '{}\\{}'.format(i.numerator, i.denominator) | |
print '\n'.join(['\t'.join([tostr(col) for col in row]) for row in matrix]) | |
OlderNewer