Example #1
0
def simulate(seed, na=2, rate=100, predict=False):
    net = NetPopPredict() if predict else NetPop(na)
    W = np.copy(net.W)
    W[:-1, :-1] *= gamma
    W -= (1 - gamma) * net.competition
    u0 = np.linspace(-2, .04, len(W))
    np.random.seed(seed)
    s, u = runpopU(W * 1. / popsize, u0, step, popsize, rate)
    pre = np.zeros((int(250 / step), len(W)))
    for t in [-40]:
        pre[int(t / step), range(-2, -2 - na, -1)] = 1
    for t in [-240, -200, -160, -120, -80, -10, -2, -1]:
        pre[int(t / step), range(-2 - na, -2 - 2 * na, -1)] = .1
    pres = np.vstack((pre, s))
    tmp = np.array([
        np.mean(np.array([
            smooth_spikes(pres[:, j * popsize + i], 40, .2)
            for i in range(popsize)
        ]),
                axis=0) for j in range(len(W) - na,
                                       len(W) - 8 * na - 1, -na)
    ])[:, 250 / step:750 / step]
    tmp2 = np.array([
        np.mean(np.array([
            smooth_spikes(pres[:, j * popsize + i], 40, .2)
            for i in range(popsize)
        ]),
                axis=0)
        for j in range(len(W) - na - 1,
                       len(W) - 8 * na - 2, -na)
    ])[:, 250 / step:750 / step]
    return [np.array(map(np.argmax, tmp)) * step, tmp, tmp2, s]
Example #2
0
def sim(u0, rate, reset, tm, th, rb, r0, r1, r2, rp, tmean, tsigma, ir, runs):
    step = .2
    net = NetPop(1)
    np.random.seed(0)
    tmp = u0 * np.ones(len(net.W))
    tmp[-1] = .5
    s = np.array([
        run(net.W,
            u0 * np.ones(len(net.W)),
            step,
            1,
            rate=rate,
            T=1700,
            tm=tm,
            reset=reset,
            seed=i,
            th=th,
            rbase=rb,
            r0=r0,
            r1=r1,
            rp=rp,
            tmean=tmean,
            tsigma=tsigma) for i in range(runs)
    ])
    s3 = np.array([
        run(net.W,
            u0 * np.ones(len(net.W)),
            step,
            1,
            rate=rate,
            T=1700,
            tm=tm,
            reset=reset,
            seed=i,
            th=th,
            rbase=rb,
            r0=r0,
            r1=r2,
            rp=rp,
            tmean=tmean,
            tsigma=tsigma) for i in range(runs)
    ])
    pre = np.ones((int(250 / step), len(net.W))) * step * ir * 100 / 1000.
    pre[:, -1] = 0
    return np.array([
        smooth_spikes(np.vstack((pre, np.mean(s3, axis=0)))[:, 1], 40, step),
        smooth_spikes(np.vstack((pre, np.mean(s3, axis=0)))[:, 0], 40, step),
        smooth_spikes(np.vstack((pre, np.mean(s, axis=0)))[:, 1], 40, step),
        smooth_spikes(np.vstack((pre, np.mean(s, axis=0)))[:, 0], 40, step),
        smooth_spikes(np.vstack((pre, np.mean(s, axis=0)))[:, 2], 40, step)
    ])
import matplotlib  # these lines to
matplotlib.use('Agg')  # work remotely
import numpy as np
import pylab as pl
from sys import path
path.append('../')
from scipy.sparse import csr_matrix
from NetPop import NetPop
import cfunctions as cfn
from functions import simpleaxis, errorfill, init_fig

init_fig()

net = NetPop(1)
W = np.copy(net.W)
dt = 1

R0 = net.R4flatPi(net.pstart_state)
Rmax = np.dot(net.calc_Qvalue().max(axis=1), net.pstart_state)

ref = 20
step = .2
rate = 400

## offline ##
try:
    perf = np.load('results/performance.npy')
except IOError:
    try:
        S = np.load('results/spikes.npz')['S']
    except IOError:
import matplotlib  # these lines to
matplotlib.use('Agg')  # work remotely
import numpy as np
import pylab as pl
from sys import path
path.append('../')
from scipy.sparse import csr_matrix
from NetPop import NetPop
import cfunctions as cfn
from functions import simpleaxis, errorfill, init_fig

init_fig()

gamma = .98
net = NetPop(1)
W = np.copy(net.W)
W[:-1, :-1] *= gamma
W -= (1 - gamma) * net.competition

R0 = net.R4flatPi(0, gamma)
Rmax = net.calc_Qvalue(gamma).max(axis=1)[0]

ref = 20
step = .2
rate = 400

## offline ##
try:
    perf = np.load('results/performance.npy')
except IOError:
    try:
Example #5
0
                    np.array([.902, .624, 0])) * i / 4 for i in range(5)]) +\
    map(tuple, [np.array([0, .62, .451]) +
                (np.array([.337, .706, .914]) -
                    np.array([0, .62, .451])) * i / 4 for i in range(1, 5)])

u0 = .2
thresh = 7
rate = 200
reset = 0.0
tm = 25.0
tdec = 300
trise = 110
tdly = 60
runs = 100
step = .2
net = NetPop(1)

##### function definitions #####


def sim(u0,
        rate,
        reset,
        tm,
        offers,
        ratio,
        tdec,
        trise,
        tdly,
        runs,
        rb=0,
pl.rc('legend', **{'fontsize': 36})
pl.rc('axes', linewidth=2)
pl.rc('xtick.major', size=10, width=1.5)
pl.rc('ytick.major', size=10, width=1.5)

# colors for colorblind from  http://www.cookbook-r.com/Graphs/Colors_(ggplot2)/
col = ['#56B4E9', '#E69F00', '#CC79A7', '#009E73']


####################
#### parameters ####
####################
gamma = .98
sigma = .5

net = NetPop(1, 3)
W = np.copy(net.W)
W[:-1, :-1] *= gamma**3
W -= (1 - gamma**3) * net.competition

valley = [8, 16]


##############################
#### function definitions ####
##############################

def get_path(x, initpv=valley, maxtrials=300):
    pv = [initpv]
    count = 0
    while count < maxtrials:
    g0 = accumulate(x)
    th = thresh * gamma ** c
    for t in range(3500):
        g = g0.next()
        if abs(g) >= th:
            break
    return t, g

popsize = 1
gamma = .7
step = .2
tau_r = 80.
rate = 100

###  simulation ###
net = NetPop()
W = np.copy(net.W)
W[:-1, :-1] *= gamma
W -= (1 - gamma) * net.competition
if deval:
    W[2, -1] /= 2.
s = []
for seed in range(30):
    u0 = np.zeros(len(W))
    np.random.seed(seed)
    s += [runU(W, u0, step, rate)]
s = np.array(s)
pre = np.zeros((int(250 / step), len(W)))
pres = np.array([np.vstack((pre, ss)) for ss in s])
Ratels = [np.array([np.mean(np.array([smooth_spikes(p[:, j * popsize + i], 40, .2)
                                      for i in range(popsize)]), axis=0)
import matplotlib      # these lines to
matplotlib.use('Agg')  # work remotely
import numpy as np
import pylab as pl
from sys import path
path.append('../')
from scipy.sparse import csr_matrix
from NetPop import NetPop
import cfunctions as cfn
from functions import simpleaxis, errorfill, init_fig

init_fig()


gamma = .98
net = NetPop(1)
W = np.copy(net.W)
W[:-1, :-1] *= gamma
W -= (1 - gamma) * net.competition

R0 = net.R4flatPi(0, gamma)
Rmax = net.calc_Qvalue(gamma).max(axis=1)[0]

ref = 20
step = .2
rate = 400

## offline ##
try:
    perf = np.load('results/performance.npy')
except IOError:
matplotlib.use("Agg")  # work remotely
import numpy as np
import pylab as pl
from sys import path

path.append("../")
from scipy.sparse import csr_matrix
from NetPop import NetPop
import cfunctions as cfn
from functions import simpleaxis, errorfill, init_fig

init_fig()


net = NetPop(1)
W = np.copy(net.W)
dt = 1

R0 = net.R4flatPi(net.pstart_state)
Rmax = np.dot(net.calc_Qvalue().max(axis=1), net.pstart_state)

ref = 20
step = 0.2
rate = 400

## offline ##
try:
    perf = np.load("results/performance.npy")
except IOError:
    try:
import cfunctions as cfn
from functions import simpleaxis, errorfill


pl.rc("figure", facecolor="white", dpi=90, frameon=False)
pl.rc("font", size=44, **{"family": "sans-serif", "sans-serif": ["Computer Modern"]})
pl.rc("lines", lw=4)
pl.rc("text", usetex=True)
pl.rc("legend", **{"fontsize": 36})
pl.rc("axes", linewidth=2)
pl.rc("xtick.major", size=10, width=1.5)
pl.rc("ytick.major", size=10, width=1.5)


gamma = 0.98
net = NetPop(1)
W = np.copy(net.W)
W[:-1, :-1] *= gamma
W -= (1 - gamma) * net.competition

R0 = net.R4flatPi(0, gamma)
Rmax = net.calc_Qvalue(gamma).max(axis=1)[0]

ref = 20
step = 0.2
rate = 400

## offline ##
try:
    perf = np.load("results/performance.npy")
except IOError:
from NetPop import NetPop
import integrate2d as cf
import cfunctions as cfn
from functions import simpleaxis, errorfill, init_fig

init_fig()
# colors for colorblind from  http://www.cookbook-r.com/Graphs/Colors_(ggplot2)/
col = ['#56B4E9', '#E69F00', '#CC79A7', '#009E73']

####################
#### parameters ####
####################
gamma = .98
sigma = .5

net = NetPop(1, 3)
W = np.copy(net.W)
W[:-1, :-1] *= gamma**3
W -= (1 - gamma**3) * net.competition

valley = [8, 16]

##############################
#### function definitions ####
##############################


def get_path(x, initpv=valley, maxtrials=300):
    pv = [initpv]
    count = 0
    while count < maxtrials: