R Kiani, TD Hanks, & MN Shadlen, JNS 2008. http://dx.doi.org/10.1523/JNEUROSCI.4761-07.2008 """ from __future__ import division import numpy as np from pyrl import tasktools # Time step dt = 1 # Inputs inputs = tasktools.to_map('FIXATION', 'LEFT', 'RIGHT') # Actions actions = tasktools.to_map('FIXATE', 'CHOOSE-LEFT', 'CHOOSE-RIGHT') # Trial conditions left_rights = [-1, 1] cohs = [0, 6.4, 12.8, 25.6, 51.2] n_conditions = len(left_rights)*len(cohs) # Training n_gradient = n_conditions n_validation = 100*n_conditions # Input noise sigma = np.sqrt(2*100*0.01)
A parametric working memory task, based on Neuronal population coding of parametric working memory. O. Barak, M. Tsodyks, & R. Romo, JNS 2010. http://dx.doi.org/10.1523/JNEUROSCI.1875-10.2010 """ from __future__ import division import numpy as np from pyrl import tasktools # Inputs inputs = tasktools.to_map('FIXATION', 'F-POS', 'F-NEG') # Actions actions = tasktools.to_map('FIXATE', '>', '<') # Trial conditions gt_lts = ['>', '<'] fpairs = [(18, 10), (22, 14), (26, 18), (30, 22), (34, 26)] n_conditions = len(gt_lts) * len(fpairs) # Training n_gradient = n_conditions n_validation = 20*n_conditions # Slow down the learning lr = 0.002
Representation of confidence associated with a decision by neurons in the parietal cortex. R. Kiani & M. N. Shadlen, Science 2009. http://dx.doi.org/10.1126/science.1169405 """ from __future__ import division import numpy as np from pyrl import tasktools # Inputs inputs = tasktools.to_map('FIXATION', 'LEFT', 'RIGHT', 'SURE') # Actions actions = tasktools.to_map('FIXATE', 'CHOOSE-LEFT', 'CHOOSE-RIGHT', 'CHOOSE-SURE') # Trial conditions wagers = [True, False] left_rights = [-1, 1] cohs = [0, 3.2, 6.4, 12.8, 25.6, 51.2] n_conditions = len(wagers) * len(left_rights) * len(cohs) # Training n_gradient = n_conditions n_validation = 50*n_conditions # Input noise
Economic choice task, based on Neurons in the orbitofrontal cortex encode economic value. C Padoa-Schioppa & JA Assad, Nature 2006. http://dx.doi.org/10.1038/nature04676 """ from __future__ import division import numpy as np from pyrl import tasktools # Inputs inputs = tasktools.to_map('FIXATION', 'L-A', 'L-B', 'R-A', 'R-B', 'N-L', 'N-R') # Actions actions = tasktools.to_map('FIXATE', 'CHOOSE-LEFT', 'CHOOSE-RIGHT') # Trial conditions A_to_B = 4.1 juices = [('A', 'B'), ('B', 'A')] offers = [(0, 1), (1, 2), (1, 1), (2, 1), (3, 1), (4, 1), (6, 1), (10, 1), (3, 0)] n_conditions = len(juices) * len(offers) # Training n_gradient = n_conditions n_validation = 50*n_conditions
Multisensory integration, based on A category-free neural population supports evolving demands during decision-making. D Raposo, MT Kaufman, & AK Churchland, Nature Neurosci. 2014. http://dx.doi.org/10.1038/nn.3865 """ from __future__ import division import numpy as np from pyrl import tasktools # Inputs inputs = tasktools.to_map('FIXATION', 'VISUAL-P', 'VISUAL-N', 'AUDITORY-P', 'AUDITORY-N') # Actions actions = tasktools.to_map('FIXATE', 'CHOOSE-LOW', 'CHOOSE-HIGH') # Trial conditions mods = ['v', 'a', 'va'] freqs = range(9, 16 + 1) n_conditions = len(mods) * len(freqs) # Discrimination boundary boundary = 12.5 # Training n_gradient = n_conditions n_validation = 50 * n_conditions
https://github.com/frsong/pyrl and add it to your PYTHONPATH, then run the code below. Requires Theano 0.8.2. """ import numpy as np import gym from pyrl import tasktools # Environment env = gym.make('CartPole-v0') # Inputs inputs = tasktools.to_map(range(env.observation_space.high.size)) # Actions actions = tasktools.to_map(range(env.action_space.n)) # Baseline bias baseline_bout = 0 # Don't treat the last time point as special abort_on_last_t = False # Training n_gradient = 1 n_validation = 0 # Network structure
Context-dependent integration task, based on Context-dependent computation by recurrent dynamics in prefrontal cortex. V Mante, D Sussillo, KV Shinoy, & WT Newsome, Nature 2013. http://dx.doi.org/10.1038/nature12742 """ from __future__ import division import numpy as np from pyrl import tasktools # Inputs inputs = tasktools.to_map('MOTION', 'COLOR', 'MOTION-LEFT', 'MOTION-RIGHT', 'COLOR-LEFT', 'COLOR-RIGHT') # Actions actions = tasktools.to_map('FIXATE', 'CHOOSE-LEFT', 'CHOOSE-RIGHT') # Trial conditions contexts = ['m', 'c'] left_rights = [-1, 1] cohs = [5, 15, 50] n_conditions = len(contexts) * (len(left_rights) * len(cohs))**2 # Training n_gradient = n_conditions n_validation = 50 * n_conditions # Input noise
""" matching pennies task, based on """ from __future__ import division import numpy as np from pyrl import tasktools import scipy.stats # Inputs inputs = tasktools.to_map('GO', 'L-R', 'R-R', 'L-N', 'R-N') """ input situations: 1. go cue 2. left reward 3. right reward 4. left no reward 5. right no reward """ # Actions actions = tasktools.to_map('HOLD', 'CHOOSE-LEFT', 'CHOOSE-RIGHT') # Trial conditions #determine what to put here later #A_to_B = 2.2 #juices = [('A', 'B'), ('B', 'A')]
A parametric working memory task, based on Neuronal population coding of parametric working memory. O. Barak, M. Tsodyks, & R. Romo, JNS 2010. http://dx.doi.org/10.1523/JNEUROSCI.1875-10.2010 """ from __future__ import division import numpy as np from pyrl import tasktools # Inputs inputs = tasktools.to_map('FIXATION', 'F-POS', 'F-NEG') # Actions actions = tasktools.to_map('FIXATE', '>', '<') # Trial conditions gt_lts = ['>', '<'] fpairs = [(18, 10), (22, 14), (26, 18), (30, 22), (34, 26)] n_conditions = len(gt_lts) * len(fpairs) # Training n_gradient = n_conditions n_validation = 20 * n_conditions # Slow down the learning lr = 0.002
Context-dependent computation by recurrent dynamics in prefrontal cortex. V Mante, D Sussillo, KV Shinoy, & WT Newsome, Nature 2013. http://dx.doi.org/10.1038/nature12742 """ from __future__ import division import numpy as np from pyrl import tasktools # Inputs inputs = tasktools.to_map('MOTION', 'COLOR', 'MOTION-LEFT', 'MOTION-RIGHT', 'COLOR-LEFT', 'COLOR-RIGHT') # Actions actions = tasktools.to_map('FIXATE', 'CHOOSE-LEFT', 'CHOOSE-RIGHT') # Trial conditions contexts = ['m', 'c'] left_rights = [-1, 1] cohs = [5, 15, 50] n_conditions = len(contexts) * (len(left_rights)*len(cohs))**2 # Training n_gradient = n_conditions n_validation = 50*n_conditions
Multisensory integration, based on A category-free neural population supports evolving demands during decision-making. D Raposo, MT Kaufman, & AK Churchland, Nature Neurosci. 2014. http://dx.doi.org/10.1038/nn.3865 """ from __future__ import division import numpy as np from pyrl import tasktools # Inputs inputs = tasktools.to_map('FIXATION', 'VISUAL-P', 'VISUAL-N', 'AUDITORY-P', 'AUDITORY-N') # Actions actions = tasktools.to_map('FIXATE', 'CHOOSE-LOW', 'CHOOSE-HIGH') # Trial conditions mods = ['v', 'a', 'va'] freqs = range(9, 16+1) n_conditions = len(mods) * len(freqs) # Discrimination boundary boundary = 12.5 # Training n_gradient = n_conditions n_validation = 50*n_conditions