示例#1
0
 def test_call_2(self):
     step = PartialStep(GradientStep(), nb_chunks=2, indice=1)
     state = {}
     function = Function()
     assert_equal(
         step(function=function, point=numpy.zeros((2)), state=state),
         numpy.array((0., -16.)))
 def test_call(self):
     step = GradientStep()
     state = {}
     function = Function()
     assert_equal(
         step(function=function, point=numpy.zeros((2)), state=state),
         numpy.array((4., -16.)))
示例#3
0
 def test_call_random(self):
     step = PartialStep(GradientStep(), nb_chunks=2)
     state = {}
     function = Function()
     direction = step(function=function,
                      point=numpy.zeros((2)),
                      state=state)
     assert ((direction == numpy.array((4., 0.))).all()
             or (direction == numpy.array((0., -16.))).all())