本文整理汇总了Python中context.Context.add_node方法的典型用法代码示例。如果您正苦于以下问题:Python Context.add_node方法的具体用法?Python Context.add_node怎么用?Python Context.add_node使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类context.Context
的用法示例。
在下文中一共展示了Context.add_node方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Context
# 需要导入模块: from context import Context [as 别名]
# 或者: from context.Context import add_node [as 别名]
s = Context()
# add stimulus sizes to root node...would be nicer if they went in stimulus node
s.add_rule('init',
'$kernel_length = 10',
'$output_length = 50',
'$bcm_radius = 4.',
'$stim_size = 20',
'$max_delay = 3')
# add all grids here? just name differently...
# NOTE: these are one longer than you think - fix?
# add a container for stimulus and 'focus' on it
s.add_node('$name = "stimulus"')
s.set_focus('$name == "stimulus"')
# add a distribution rule for stimulus points
s.add_rule('init',
# dx and dy were initially 2 for both of these, changing temporarily
'$stim_grid = Grid(xl=$stim_size, yl=$stim_size, dx=1, dy=1)',
# should just reset stim_grid instead of copying?
'$bph_grid = Grid(xl=$stim_size, yl=$stim_size, dx=1, dy=1)')
#'print $stim_grid.positions')
# also maintain a matrix of stimulus values for stimulus points to access
s.add_rule('init',
#'$stim = SinusoidStim($stim_size, $stim_size)', # why two?
#'$stim = JigglySinusoidStim($stim_size, 10)',
#'$stim = InvertingSinusoidStim($stim_size, 20)',
示例2: Context
# 需要导入模块: from context import Context [as 别名]
# 或者: from context.Context import add_node [as 别名]
from context import Context
s = Context()
# how to have input layer?...Need input layer? lolz
ps = PretendStimulus(....)
s.add_node('photoreceptor', is_worker=True, ..., focus=True)
# how to assign inputs appropriately?
# just...add a function to each node that allows it to get the next relevant
# stimulus point...could pass own position to stimulus, then stimulus returns
# relevant value?'
# and do positioning as before, with just a function that each unit can ask
# for a position from.
# should have a way to reset distribution functions when simulation is reset?
# something like
s.add_step('update', store(access_input, ps)) # have s.store? will passing ps like this work?
# or something
# and access_input basically gets a node to pass its position to ps and then update its output in the right way
示例3: SinusoidStim
# 需要导入模块: from context import Context [as 别名]
# 或者: from context.Context import add_node [as 别名]
#'$stim = SinusoidStim($stim_size, $stim_size)', # why two?
#'$stim = JigglySinusoidStim($stim_size, 10)',
#'$stim = InvertingSinusoidStim($stim_size, 20)',
#'$stim = SquareWaveStim($stim_size, 8)',
#'$stim = BarStim($stim_size, 10)',
'$stim = FullFieldStim($stim_size, 20)',
'$stim.step()',
'$stim_data = $stim.output')
s.add_rule('update',
'$stim.step()',
'$stim_data = $stim.output')
# add photoreceptors (don't specify connections?)
s.add_node('$name = "p_layer"')
s.set_focus('$name == "p_layer"')
s.add_node('$name = "photoreceptor"')
s.set_focus('$name == "photoreceptor"')
# read from associated position in stimulus matrix
s.add_rule('init',
'$x, $y = $stim_grid.get_next()',
'$init_data($output_length)')
s.add_rule('interact',
'$temp_data = $stim_data[$x][$y]')
s.add_rule('update',
'$append_data($temp_data)',
'$clean_data($output_length)')
# ADD APPROPRIATE IRF!!