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 | |
import pickle | |
import numpy as np | |
# Create a simple example | |
x = T.matrix('x') | |
y = x + x | |
env = theano.Env([x], [y]) |
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
def shape_of_variables(env, input_shapes): | |
""" | |
Inputs: | |
env - the theano.Env in question | |
input_shapes - a dict mapping input to shape | |
Outputs: | |
shapes - a dict mapping variable to shape | |
WARNING : This modifies the env! Not pure! |
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 | |
import re | |
import networkx as nx | |
import os | |
prog = re.compile("class (?P<subclass>\w+)\((?P<superclasses>[\s\w,]+)\):") | |
def grep_stream(location): | |
return os.popen( |
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.sandbox.linalg as linalg | |
mu = theano.tensor.matrix('mu') | |
Sigma = theano.tensor.matrix('Sigma') | |
H = theano.tensor.matrix('H') | |
R = theano.tensor.matrix('R') | |
data = theano.tensor.matrix('data') | |
dot = theano.tensor.dot |
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 | |
from theano.tensor.io import send, recv, mpi_cmps | |
import theano.sandbox.linalg as linalg | |
from theano.gof.sched import sort_schedule_fn | |
from time import time | |
dot = theano.tensor.dot | |
dtype = 'float32' | |
n = 500 | |
run = False |
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
#include <stdio.h> | |
#include <sys/time.h> | |
const int n = 16000000; | |
// Print number of milliseconds between timevals | |
void printDuration(timeval a, timeval b, char* message) | |
{ | |
double elapsedTime = (b.tv_sec - a.tv_sec) * 1000.0; | |
elapsedTime += (b.tv_usec - a.tv_usec) / 1000.0; |
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
! Answers discussion in the following SO question | |
! http://stackoverflow.com/questions/4637888/where-can-i-find-blas-example-code-in-fortran/ | |
! Author: Matthew Rocklin | |
! Disclaimer: This is my first Fortran program. Please do not judge. | |
implicit none | |
integer, parameter :: N=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
In [1]: from sympy.stats import * | |
In [2]: x0 = Symbol('x0', real=True, bounded=True) | |
In [3]: gamma = Symbol('gamma', positive=True) | |
In [4]: X = Cauchy('X', x0, gamma) | |
In [5]: density(X)(x) | |
Out[5]: |
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
In [1]: from sympy.stats import * | |
In [2]: nu = Symbol("nu", positive=True) | |
In [3]: X = StudentT("x", nu) | |
In [4]: density(X)(x) | |
Out[4]: | |
ν 1 | |
- ─ - ─ |
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 numpy import linspace, sin | |
from pylab import plot, figure, show | |
def plotFunction(f): | |
""" Plot a function on the domain x in (-10, 10) """ | |
xs = linspace(-10, 10, 100) | |
ys = map(f, xs) | |
plot(xs, ys) | |
def derivative(f, dx=.00001): |
OlderNewer