Beispiel #1
0
 def test_directly_constructed(self):
     x = Constant(1.0, 'x')
     y = Constant(2.0, 'y')
     s = Summation('summation', [x, y])
     v = s()
     with self.test_session() as sess:
         assert sess.run(v) == 3.0
Beispiel #2
0
 def get_data(self):
     path = self.resource_path() / 'model' / 'projection' / 'ToR'
     image = np.load(path / 'test_image.npy')
     with open(path / 'config.json') as fin:
         config = json.load(fin)
     image = Constant(image, 'image')
     assert tuple(image.shape) == tuple(config['grid'])
     image = Image(image, config['center'], config['size'])
Beispiel #3
0
 def get_data(self):
     path = self.resource_path / 'physics' / 'ToRMap'
     image = np.load(path / 'test_image.npy').astype(np.float32)
     with open(path / 'config.json') as fin:
         config = json.load(fin)
     image = Constant(image, 'image')
     assert tuple(image.shape) == tuple(config['grid'])
     image = Image(image, config['center'], config['size'])
     lors = np.load(path / 'test_lors.npy')
Beispiel #4
0
 def get_data(self):
     path = self.resource_path / 'physics' / 'Siddon'
     image = np.load(path / 'test_image.npy').astype(np.float32)
     with open(path / 'config.json') as fin:
         config = json.load(fin)
     image = Constant(image, 'image')
     assert tuple(image.shape) == tuple(config['grid'])
     image = Image(image, config['center'], config['size'])
     lors = np.load(path / 'test_lors.npy').astype(np.float32)
     lors = Constant(lors, 'lors')
     projected = np.load(path / 'test_projection.npy')
     back_projected = np.load(path / 'test_backprojection.npy')
     lors_value = Constant(projected, 'lors_value')
     return {
         'image': image,
         'lors': lors,
         'lors_value': lors_value,
         'projected': projected,
         'backprojected': back_projected
     }
Beispiel #5
0
 def test_inputs(self):
     x = Constant(1.0, 'x')
     s = Summation('summation', [x] * 3)
     assert s.tensors['input'] == [x] * 3
Beispiel #6
0
 def test_construct_with_none_input(self):
     x = Constant(1.0, 'x')
     s = Summation('summation')
     v = s([x] * 3)
     with self.test_session() as sess:
         assert sess.run(v) == 3.0
Beispiel #7
0
 def test_summation_of_same_tensor(self):
     x = Constant(1.0, 'x')
     s = Summation('summation', [x, x, x])
     v = s()
     with self.test_session() as sess:
         assert sess.run(v) == 3.0
Beispiel #8
0
 def test_run_list(self):
     c = Constant(1.0, 'const')
     with self.test_session() as sess:
         assert sess.run([c, c]) == [1.0, 1.0]
Beispiel #9
0
 def load(self, target_graph):
     return {
         'projection_data':
         Constant(np.ones([30, 7]), 'projection_data')
     }, ()
Beispiel #10
0
 def kernel(self, inputs):
     return Constant(5 * np.ones([5] * 3, dtype=np.float32),
                     'result')
Beispiel #11
0
 def get_subset(self):
     s = Constant(1, 'subset')
     return s
Beispiel #12
0
 def get_dummy_input(self):
     return Constant(1.0, 'x')
Beispiel #13
0
 def make_dummy_tensor(self, info=None):
     from dxl.learn.core import Constant
     if info is None:
         info = str(uuid.uuid4())
     return Constant(0.0, info)