コード例 #1
0
  def test_skip(self):
    dim = 10
    n = 50
    skip = 17
    for dtype in [np.float64, np.float32]:
      sample_noskip = math_ops.sobol_sample(dim, n + skip, dtype=dtype)
      sample_skip = math_ops.sobol_sample(dim, n, skip, dtype=dtype)

      self.assertAllClose(
          self.evaluate(sample_noskip)[skip:, :], self.evaluate(sample_skip))
コード例 #2
0
 def test_more_known_values(self):
   for dtype in [np.float64, np.float32]:
     sample = math_ops.sobol_sample(5, 31, dtype=dtype)
     expected = [[0.50, 0.50, 0.50, 0.50, 0.50],
                 [0.75, 0.25, 0.25, 0.25, 0.75],
                 [0.25, 0.75, 0.75, 0.75, 0.25],
                 [0.375, 0.375, 0.625, 0.875, 0.375],
                 [0.875, 0.875, 0.125, 0.375, 0.875],
                 [0.625, 0.125, 0.875, 0.625, 0.625],
                 [0.125, 0.625, 0.375, 0.125, 0.125],
                 [0.1875, 0.3125, 0.9375, 0.4375, 0.5625],
                 [0.6875, 0.8125, 0.4375, 0.9375, 0.0625],
                 [0.9375, 0.0625, 0.6875, 0.1875, 0.3125],
                 [0.4375, 0.5625, 0.1875, 0.6875, 0.8125],
                 [0.3125, 0.1875, 0.3125, 0.5625, 0.9375],
                 [0.8125, 0.6875, 0.8125, 0.0625, 0.4375],
                 [0.5625, 0.4375, 0.0625, 0.8125, 0.1875],
                 [0.0625, 0.9375, 0.5625, 0.3125, 0.6875],
                 [0.09375, 0.46875, 0.46875, 0.65625, 0.28125],
                 [0.59375, 0.96875, 0.96875, 0.15625, 0.78125],
                 [0.84375, 0.21875, 0.21875, 0.90625, 0.53125],
                 [0.34375, 0.71875, 0.71875, 0.40625, 0.03125],
                 [0.46875, 0.09375, 0.84375, 0.28125, 0.15625],
                 [0.96875, 0.59375, 0.34375, 0.78125, 0.65625],
                 [0.71875, 0.34375, 0.59375, 0.03125, 0.90625],
                 [0.21875, 0.84375, 0.09375, 0.53125, 0.40625],
                 [0.15625, 0.15625, 0.53125, 0.84375, 0.84375],
                 [0.65625, 0.65625, 0.03125, 0.34375, 0.34375],
                 [0.90625, 0.40625, 0.78125, 0.59375, 0.09375],
                 [0.40625, 0.90625, 0.28125, 0.09375, 0.59375],
                 [0.28125, 0.28125, 0.15625, 0.21875, 0.71875],
                 [0.78125, 0.78125, 0.65625, 0.71875, 0.21875],
                 [0.53125, 0.03125, 0.40625, 0.46875, 0.46875],
                 [0.03125, 0.53125, 0.90625, 0.96875, 0.96875]]
     self.assertAllClose(expected, self.evaluate(sample), .001)
コード例 #3
0
 def f(num_results):
   s = math_ops.sobol_sample(10, num_results, dtype=dtypes.float32)
   assert s.shape.as_list() == [None, 10]
   return s
コード例 #4
0
 def f(dim):
   s = math_ops.sobol_sample(dim, 100, dtype=dtypes.float32)
   assert s.shape.as_list() == [100, None]
   return s
コード例 #5
0
 def test_static_shape(self):
   s = math_ops.sobol_sample(10, 100, dtype=np.float32)
   self.assertAllEqual([100, 10], s.shape.as_list())
コード例 #6
0
 def test_basic(self):
   for dtype in [np.float64, np.float32]:
     expected = np.array([[.5, .5], [.75, .25], [.25, .75], [.375, .375]])
     sample = self.evaluate(math_ops.sobol_sample(2, 4, dtype=dtype))
     self.assertAllClose(expected, sample, 0.001)
コード例 #7
0
 def test_default_dtype(self):
   # Create an op without specifying the dtype. Dtype should be float32 in
   # this case.
   s = math_ops.sobol_sample(10, 100)
   self.assertEqual(dtypes.float32, s.dtype)
コード例 #8
0
 def test_dynamic_shape(self):
   s = math_ops.sobol_sample(10, 100, dtype=dtypes.float32)
   self.assertAllEqual([100, 10], self.evaluate(s).shape)