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/env python | |
import matplotlib.pyplot as plt | |
import numpy | |
class SublotsForReuse(object): | |
def __init__(self, *args, **kwds): | |
self.fig = plt.figure(*args, **kwds) | |
self.ax = [] |
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 matplotlib.pyplot as plt | |
from mpl_toolkits.axes_grid import AxesGrid | |
import numpy | |
class MultiSeqPlotter(object): | |
""" | |
Reuseable multi-sequence plotter for plotting some time series | |
of some variables. Time series are column-wise and variables are | |
row-wise. | |
""" |
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
list_func = [ lambda x: numpy.sin(x), | |
lambda x: numpy.sin(0.1*x), | |
lambda x: numpy.sin(x)*numpy.sin(0.1*x) ] | |
list_tmax = [30,50,70,100,200] | |
dt = 1 | |
nrows_ncols = (len(list_func), len(list_tmax)) | |
num_steps = sum(list_tmax) * dt | |
num_rows = len(list_func) |
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
# -*- coding: utf-8 -*- | |
import os | |
import cgi | |
## import cgitb | |
## cgitb.enable() | |
caldir_path = "../path/to/cal/" | |
calset = set(['cal1','cal2','cal3',]) | |
fs = cgi.FieldStorage() |
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
""" | |
x[t] = fp(u)[t] = tanh(v[t]) | |
v[t] = mean( u[t-T+1:t+1] ) = ( u[t-T+1] + u[t-T+2] + ... + u[t-1] + u[t] )/T | |
E = sum( 0.5 * (x - y)**2 ) | |
dE/dv[t] = (x[t] - y[t]) * (1 - x[t]**2) | |
dE/du[t] = mean( dE/dv[t:t+T] ) | |
= ( dE/dv[t+T-1] + dE/dv[t+T-2] + ... + dE/dv[t+1] + dE/dv[t] )/T | |
See result here: http://www.flickr.com/photos/arataka/tags/up20091213135244/show/ |
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
""" | |
x[t] = fp(u)[t] | |
= mean( v[t-T+1:t+1] ) = ( v[t-T+1] + v[t-T+2] + ... + v[t-1] + v[t] )/T | |
v[t] = tanh(u[t]) | |
E = sum( 0.5 * (x - y)**2 ) | |
dE/dx[t] = x[t] - y[t] | |
dE/dv[t] = ( dE/dx[t+T-1] + dE/dx[t+T-2] + ... + dE/dx[t+1] + dE/dx[t] )/T | |
dE/du[t] = dE/dv[t] * (1 - x[t]**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
ALL = \ | |
rnn_ca1d-gcc-O2 rnn_ca1d-gcc-O3 rnn_ca1d-icc-O2 rnn_ca1d-icc-O3 \ | |
rnn_ca2d-gcc-O2 rnn_ca2d-gcc-O3 rnn_ca2d-icc-O2 rnn_ca2d-icc-O3 \ | |
rnn_opt0-gcc-O2 rnn_opt0-gcc-O3 rnn_opt0-icc-O2 rnn_opt0-icc-O3 \ | |
rnn_opt1-gcc-O2 rnn_opt1-gcc-O3 rnn_opt1-icc-O2 rnn_opt1-icc-O3 \ | |
rnn_opt2-gcc-O2 rnn_opt2-gcc-O3 rnn_opt2-icc-O2 rnn_opt2-icc-O3 \ | |
rnn_opt3-gcc-O2 rnn_opt3-gcc-O3 rnn_opt3-icc-O2 rnn_opt3-icc-O3 \ | |
rnn_opt4-gcc-O2 rnn_opt4-gcc-O3 rnn_opt4-icc-O2 rnn_opt4-icc-O3 \ | |
#ALL = \ |
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 math | |
from pylab import * | |
import random | |
def mixture_gaussian(i): | |
pi_0 = 0.3 | |
if random.random() < pi_0: | |
return random.gauss(-5, 1) | |
else: | |
return random.gauss( 5, 4) |
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 re | |
FORMAT_PATTERN_GROUPED = re.compile("{([^}]+):([^}]+)}") | |
FORMAT_PATTERN = re.compile("{[^}]+:[^}]+}") | |
def find_variables(formatstr, strlist): | |
""" | |
Extract values from fixed formatted string. | |
(e.g., '1' and '1000.0' from '001_1E3.txt') | |