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 fired(inputs, threshold): | |
if sum(inputs) > threshold: | |
return True | |
else: | |
return 0 |
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
type NeuralNet | |
weight_matrices::Array{Array{FloatingPoint}} | |
NeuralNet(layer_sizes::Array{Int64}) = new([ | |
rand(layer_sizes[i], layer_sizes[i+1]) for i in [1:length(layer_sizes)-1] | |
]) | |
end | |
function predict(input_vector::Array{Float64}, net::NeuralNet) | |
unshift!(net.weight_matrices, input_vector) |
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 transfer_function(x, y): | |
return np.power(np.prod(x, axis=1)[:, None] * np.prod(y, axis=0), 1./x.shape[1]) | |
def gnn(c): | |
return normalize([np.random.random(c[i] * c[i + 1]).reshape((c[i], c[i + 1])) for i in range(len(c) - 1)]) | |
def predict(weights, input_vector, reverse=False): | |
current_net = [input_vector] + weights |
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 collections | |
def rec_dict(): | |
""" | |
Just a recursive dictionary | |
""" | |
return collections.defaultdict(rec_dict) | |
class Tree(object): |
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 flask | |
import sys | |
from flask import Flask, request | |
import random | |
from lxml import etree | |
import xmltodict | |
import numpy as np | |
import operator | |
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 pyfuzz.generator import random_regex | |
from guess_language import guessLanguageName | |
from collections import Counter | |
def randomness_histogram(iterations, length): | |
return Counter((guessLanguageName(random_regex(regex="[a-z \n]", length=length)) for i in xrange(length))) | |
print randomness_histogram(1000, 200).most_common(10) # returns the 10 most common languages | |
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 collections import Counter | |
import cPickle as pickle | |
import random | |
import itertools | |
import string | |
def words(entry): | |
return [word.lower().decode('ascii', 'ignore') for word in entry.split()] | |
def letters(entry): |
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 random_document(document_layout, type, **kwargs): | |
document_layout.append("dummy_item") | |
doc = lambda l:{l[i]:doc(l[i+1]) if isinstance(l[i+1],list) else random_item(type,**kwargs) for i in range(len(l)-1)} | |
return doc(document_layout) |
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
{ | |
"mappings": { | |
"properties": { | |
"searchable_text": { | |
"type": "multi_field", | |
"fields": { | |
"full_words": { | |
"type": "string", | |
"store": "yes", | |
"index": "analyzed", |
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 flask import Blueprint, request, redirect, render_template, url_for | |
from flask.views import MethodView | |
from flask.ext.mongoengine.wtf import model_form | |
from SpoolEngine.auth import requires_auth | |
from SpoolEngine.models import Post, BlogPost, Video, Image, Quote, Comment | |
admin = Blueprint('admin', __name__, template_folder='templates') |