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
#!/usr/bin/python | |
div1 = ["Lions", "Tigers", "Jaguars", "Cougars"] | |
div2 = ["Whales", "Sharks", "Piranhas", "Alligators"] | |
div3 = ["Cubs", "Kittens", "Puppies", "Calfs"] | |
def create_schedule(list): | |
""" Create a schedule for the teams in the list and return it""" | |
s = [] |
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
# Euclidean distance. | |
def euc_dist(pt1,pt2): | |
return math.sqrt((pt2[0]-pt1[0])*(pt2[0]-pt1[0])+(pt2[1]-pt1[1])*(pt2[1]-pt1[1])) | |
def _c(ca,i,j,P,Q): | |
if ca[i,j] > -1: | |
return ca[i,j] | |
elif i == 0 and j == 0: | |
ca[i,j] = euc_dist(P[0],Q[0]) | |
elif i > 0 and j == 0: |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
{0: 'tench, Tinca tinca', | |
1: 'goldfish, Carassius auratus', | |
2: 'great white shark, white shark, man-eater, man-eating shark, Carcharodon carcharias', | |
3: 'tiger shark, Galeocerdo cuvieri', | |
4: 'hammerhead, hammerhead shark', | |
5: 'electric ray, crampfish, numbfish, torpedo', | |
6: 'stingray', | |
7: 'cock', | |
8: 'hen', | |
9: 'ostrich, Struthio camelus', |
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 theano | |
import theano.tensor as T | |
from theano.tensor.shared_randomstreams import RandomStreams | |
from theano.sandbox.rng_mrg import MRG_RandomStreams | |
from lasagne.updates import adam | |
from lasagne.utils import collect_shared_vars | |
from sklearn.datasets import fetch_mldata | |
from sklearn.cross_validation import train_test_split | |
from sklearn import preprocessing |
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 __future__ import print_function | |
from keras.datasets import cifar10 | |
from keras.layers import merge, Input | |
from keras.layers.convolutional import Convolution2D, ZeroPadding2D, AveragePooling2D | |
from keras.layers.core import Dense, Activation, Flatten | |
from keras.layers.normalization import BatchNormalization | |
from keras.models import Model | |
from keras.preprocessing.image import ImageDataGenerator | |
from keras.utils import np_utils |
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
""" Trains an agent with (stochastic) Policy Gradients on Pong. Uses OpenAI Gym. """ | |
import numpy as np | |
import cPickle as pickle | |
import gym | |
# hyperparameters | |
H = 200 # number of hidden layer neurons | |
batch_size = 10 # every how many episodes to do a param update? | |
learning_rate = 1e-4 | |
gamma = 0.99 # discount factor for reward |
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
""" | |
Example TensorFlow script for finetuning a VGG model on your own data. | |
Uses tf.contrib.data module which is in release v1.2 | |
Based on PyTorch example from Justin Johnson | |
(https://gist.github.com/jcjohnson/6e41e8512c17eae5da50aebef3378a4c) | |
Required packages: tensorflow (v1.2) | |
Download the weights trained on ImageNet for VGG: | |
``` | |
wget http://download.tensorflow.org/models/vgg_16_2016_08_28.tar.gz |
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 collections import namedtuple | |
import leven # install through pip first | |
import numpy as np | |
SparseTensor = namedtuple('SparseTensor', 'indices vals shape') | |
PHN_MAPPING = {'iy': 'iy', 'ix': 'ix', 'ih': 'ix', 'eh': 'eh', 'ae': 'ae', 'ax': 'ax', 'ah': 'ax', | |
'ax-h': 'ax', 'uw': 'uw', 'ux': 'uw', 'uh': 'uh', 'ao': 'ao', 'aa': 'ao', 'ey': 'ey', |
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
{0: {'id': '01440764-n', | |
'label': 'tench, Tinca tinca', | |
'uri': 'http://wordnet-rdf.princeton.edu/wn30/01440764-n'}, | |
1: {'id': '01443537-n', | |
'label': 'goldfish, Carassius auratus', | |
'uri': 'http://wordnet-rdf.princeton.edu/wn30/01443537-n'}, | |
2: {'id': '01484850-n', | |
'label': 'great white shark, white shark, man-eater, man-eating shark, Carcharodon carcharias', | |
'uri': 'http://wordnet-rdf.princeton.edu/wn30/01484850-n'}, | |
3: {'id': '01491361-n', |
OlderNewer