Exemple #1
0
 def test_enter_exit(self):
     reporter1 = chainer.Reporter()
     reporter2 = chainer.Reporter()
     with reporter1:
         self.assertIs(chainer.get_current_reporter(), reporter1)
         with reporter2:
             self.assertIs(chainer.get_current_reporter(), reporter2)
         self.assertIs(chainer.get_current_reporter(), reporter1)
Exemple #2
0
 def test_enter_exit(self):
     reporter1 = chainer.Reporter()
     reporter2 = chainer.Reporter()
     with reporter1:
         self.assertIs(chainer.get_current_reporter(), reporter1)
         with reporter2:
             self.assertIs(chainer.get_current_reporter(), reporter2)
         self.assertIs(chainer.get_current_reporter(), reporter1)
Exemple #3
0
 def test_scope(self):
     reporter1 = chainer.Reporter()
     reporter2 = chainer.Reporter()
     with reporter1:
         observation = {}
         with reporter2.scope(observation):
             self.assertIs(chainer.get_current_reporter(), reporter2)
             self.assertIs(reporter2.observation, observation)
         self.assertIs(chainer.get_current_reporter(), reporter1)
         self.assertIsNot(reporter2.observation, observation)
Exemple #4
0
 def test_scope(self):
     reporter1 = chainer.Reporter()
     reporter2 = chainer.Reporter()
     with reporter1:
         observation = {}
         with reporter2.scope(observation):
             self.assertIs(chainer.get_current_reporter(), reporter2)
             self.assertIs(reporter2.observation, observation)
         self.assertIs(chainer.get_current_reporter(), reporter1)
         self.assertIsNot(reporter2.observation, observation)
Exemple #5
0
 def thread_func(reporter, record):
     with reporter:
         # Sleep for a tiny moment to cause an overlap of the context
         # managers.
         time.sleep(0.01)
         record.append(chainer.get_current_reporter())