本文整理汇总了Python中context.Context.add_rule方法的典型用法代码示例。如果您正苦于以下问题:Python Context.add_rule方法的具体用法?Python Context.add_rule怎么用?Python Context.add_rule使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类context.Context
的用法示例。
在下文中一共展示了Context.add_rule方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Context
# 需要导入模块: from context import Context [as 别名]
# 或者: from context.Context import add_rule [as 别名]
to operate on only a single output vector...better way of doing?
TODO: Would be nice to add something that catches exceptions when ExecSteps
or Constraints don't work and tells you what the string is.
TODO: Have warnings when variables are made without being prepended by $ or
other?
TODO: Why is nothing shown for initialization during copies?
TODO: Appending to numpy arrays is bad, do some other way
"""
# create context
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',
'$time_delay = 5')
# 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',
'$child_grid = Grid(xl=$stim_size, yl=$stim_size, dx=2, dy=2)',
'print $child_grid.positions')
示例2: Context
# 需要导入模块: from context import Context [as 别名]
# 或者: from context.Context import add_rule [as 别名]
to operate on only a single output vector...better way of doing?
TODO: Have warnings when variables are made without being prepended by $ or
other?
TODO: Why is nothing shown for initialization during copies?
TODO: Could....add a second init step so there's one before connections
and one after?
TODO: want to change copy_node so that it takes constraints?
"""
# create context
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)',
示例3: Context
# 需要导入模块: from context import Context [as 别名]
# 或者: from context.Context import add_rule [as 别名]
s = Context()
# add stimulus sizes to root node...would be nicer if they went in stimulus node
s.add_rule('init',
# NOTE: these are one longer than you think - fix?
'$kernel_length = 10',
'$output_length = 50',
'$stim_size = 20',
'$p_h_radius = 500.',
'$p_b_radius = 500.',
'$h_b_radius = 500.',
'$b_a_radius = 500.',
'$b_g_radius = 500.',
'$a_g_radius = 500.',
'$stim_grid = Grid(xl=$stim_size, yl=$stim_size, dx=1, dy=1)',
'$p_grid = Grid(xl=$stim_size, yl=$stim_size, dx=1, dy=1)',
'$h_grid = Grid(xl=$stim_size, yl=$stim_size, dx=1, dy=1)',
'$b_grid = Grid(xl=$stim_size, yl=$stim_size, dx=1, dy=1)',
'$a_grid = Grid(xl=$stim_size, yl=$stim_size, dx=1, dy=1)',
'$g_grid = Grid(xl=$stim_size, yl=$stim_size, dx=1, dy=1)',
#'$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')