本文整理汇总了Python中pln.chainers.Chainer._apply_backward方法的典型用法代码示例。如果您正苦于以下问题:Python Chainer._apply_backward方法的具体用法?Python Chainer._apply_backward怎么用?Python Chainer._apply_backward使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pln.chainers.Chainer
的用法示例。
在下文中一共展示了Chainer._apply_backward方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: RulesTest
# 需要导入模块: from pln.chainers import Chainer [as 别名]
# 或者: from pln.chainers.Chainer import _apply_backward [as 别名]
class RulesTest(TestCase):
def setUp(self):
self.atomspace = AtomSpace()
self.chainer = Chainer(self.atomspace)
def tearDown(self):
del self.atomspace
del self.chainer
def _inh_animal_breathe(self):
'''InheritanceLink animal breathe'''
default_av = {'sti':1}
self.animal = self.atomspace.add_node(types.ConceptNode, "animal")
self.breathe = self.atomspace.add_node(types.ConceptNode, "breathe")
self.inh_animal_breathe = self.atomspace.add_link(types.InheritanceLink, [self.animal, self.breathe])
self.animal.tv = TruthValue(0.1, 1)
self.breathe.tv = TruthValue(0.1, 1)
self.inh_animal_breathe.tv = TruthValue(1, 1)
atoms = []
atoms.append( self.animal )
atoms.append( self.breathe )
atoms.append( self.inh_animal_breathe )
for atom in atoms:
atom.av = default_av
return atoms
# def _apply_rule(self, rule,
def test_standardize_apart_input_output(self):
rule = rules.InversionRule(self.chainer, types.InheritanceLink)
(input, output) = rule.standardize_apart_input_output(self.chainer)
def test_InversionRule(self):
rule = rules.InversionRule(self.chainer, types.InheritanceLink)
self._inh_animal_breathe()
result = self.chainer._apply_forward(rule)
print result
def test_InversionRule_backward(self):
rule = rules.InversionRule(self.chainer, types.InheritanceLink)
self._inh_animal_breathe()
self.inh_breathe_animal = self.atomspace.add_link(types.InheritanceLink, [self.breathe, self.animal])
self.inh_breathe_animal.av = {'sti':1}
result = self.chainer._apply_backward(rule)
print result
def disabled_test_rules_generically(self):
'''See what happens if you give a rule the generic inputs. This makes sure that the rule and formula don't have any basic code errors, but doesn't check that they do the right thing.'''
def apply_rule(rule):
generic_inputs = rule.inputs
generic_outpus = rule.outputs
# Take the generic required input atoms and give them boring TVs
for atom in generic_inputs:
atom.av = {'sti':1}
atom.tv = TruthValue(1, 1)
status = self.chainer._apply_forward(rule)
self.assertNotEquals(status, None)
return None
for rule in self.chainer.rules:
apply_rule(rule)