コード例 #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)
コード例 #2
0
ファイル: test_reporter.py プロジェクト: MakotoSeto/chainer
 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)
コード例 #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)
コード例 #4
0
ファイル: test_reporter.py プロジェクト: MakotoSeto/chainer
 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)
コード例 #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())