Skip to content

Commit f05a4bb

Browse files
dsharletgtensorflower-gardener
authored andcommitted
Automated Code Change
PiperOrigin-RevId: 906487960
1 parent c847a41 commit f05a4bb

7 files changed

Lines changed: 22 additions & 15 deletions

File tree

tensorflow_probability/python/distributions/BUILD

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4943,7 +4943,7 @@ py_test(
49434943
# hypothesis dep,
49444944
# numpy dep,
49454945
# six dep,
4946-
# tensorflow dep,
4946+
# tensorflow:tensorflow_no_contrib dep,
49474947
"//tensorflow_probability/python/internal:hypothesis_testlib",
49484948
"//tensorflow_probability/python/internal:tensor_util",
49494949
"//tensorflow_probability/python/internal:test_util",

tensorflow_probability/python/distributions/half_normal_test.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ def testHalfNormalMeanAndMode(self):
198198
expected_mean = scale * np.sqrt(2.0) / np.sqrt(np.pi)
199199

200200
self.assertAllEqual((3,), self.evaluate(halfnorm.mean()).shape)
201-
self.assertAllEqual(expected_mean, self.evaluate(halfnorm.mean()))
201+
self.assertAllClose(expected_mean, self.evaluate(halfnorm.mean()))
202202

203203
self.assertAllEqual((3,), self.evaluate(halfnorm.mode()).shape)
204204
self.assertAllEqual([0., 0., 0.], self.evaluate(halfnorm.mode()))
@@ -209,16 +209,17 @@ def testHalfNormalVariance(self):
209209
expected_variance = scale**2.0 * (1.0 - 2.0 / np.pi)
210210

211211
self.assertAllEqual((3,), self.evaluate(halfnorm.variance()).shape)
212-
self.assertAllEqual(expected_variance, self.evaluate(halfnorm.variance()))
212+
self.assertAllClose(expected_variance, self.evaluate(halfnorm.variance()))
213213

214214
def testHalfNormalStandardDeviation(self):
215215
scale = np.array([7., 7., 7.])
216216
halfnorm = half_normal.HalfNormal(scale=scale, validate_args=True)
217217
expected_variance = scale**2.0 * (1.0 - 2.0 / np.pi)
218218

219219
self.assertAllEqual((3,), halfnorm.stddev().shape)
220-
self.assertAllEqual(
221-
np.sqrt(expected_variance), self.evaluate(halfnorm.stddev()))
220+
self.assertAllClose(
221+
np.sqrt(expected_variance), self.evaluate(halfnorm.stddev())
222+
)
222223

223224
def testHalfNormalSample(self):
224225
scale = tf.constant(3.0)

tensorflow_probability/python/distributions/platform_compatibility_test.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,7 @@
173173
'Logistic': 3e-6,
174174
'Multinomial': 2e-4,
175175
'NoncentralChi2': 1e-4,
176+
'Normal': 5e-6,
176177
'OneHotCategorical': 1e-5,
177178
'PERT': 1e-5,
178179
'PowerSpherical': 2e-5,
@@ -206,16 +207,17 @@
206207
'InverseGamma': 5e-3,
207208
'JohnsonSU': 1e-2,
208209
'LambertWNormal': 1e-5,
209-
'LKJ': .07,
210+
'LKJ': 0.07,
210211
'Multinomial': 3e-4,
211212
'MultivariateNormalDiag': 5e-6,
212213
'MultivariateNormalFullCovariance': 1e-5,
213214
'MultivariateNormalTriL': 1e-5,
215+
'Normal': 5e-6,
214216
'MultivariateNormalDiagPlusLowRankCovariance': 1e-4,
215217
'OneHotCategorical': 1e-3, # TODO(b/163118820)
216218
'PERT': 5e-4,
217219
'Poisson': 3e-2, # TODO(b/159999573)
218-
'PowerSpherical': .003,
220+
'PowerSpherical': 0.003,
219221
'RelaxedBernoulli': 3e-3,
220222
'RelaxedOneHotCategorical': 2e-3, # TODO(b/163118820)
221223
'SigmoidBeta': 5e-4,

tensorflow_probability/python/experimental/fastgp/BUILD

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,7 @@ py_test(
145145
shard_count = 3,
146146
# strict_deps = False, # DisableOnExport
147147
deps = [
148+
":fast_gp",
148149
":fast_mtgp",
149150
# absl/testing:absltest dep,
150151
# jax dep,
@@ -293,6 +294,7 @@ py_test(
293294
# absl/testing:absltest dep,
294295
# absl/testing:parameterized dep,
295296
# jax dep,
297+
# numpy dep,
296298
"//tensorflow_probability/python/internal/backend/jax",
297299
],
298300
)

tensorflow_probability/python/experimental/fastgp/fast_mtgp_test.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -350,7 +350,7 @@ def slow_log_prob(amplitude, length_scale, noise):
350350
slow_value, slow_gradient = jax.value_and_grad(
351351
slow_log_prob, argnums=[0, 1, 2]
352352
)(self.dtype(1.0), self.dtype(1.0), self.dtype(1e-3))
353-
np.testing.assert_allclose(value, slow_value, rtol=1e-3)
353+
np.testing.assert_allclose(value, slow_value, rtol=5e-3)
354354
slow_d_amp, slow_d_length_scale, slow_d_noise = slow_gradient
355355
np.testing.assert_allclose(d_amp, slow_d_amp, rtol=2e-4)
356356
np.testing.assert_allclose(d_length_scale, slow_d_length_scale, rtol=2e-4)

tensorflow_probability/python/experimental/fastgp/preconditioners_test.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ def test_partial_cholesky_preconditioner(self):
102102
self.assertAlmostEqual(jnp.log(7.0), pcp.log_det(), places=5)
103103
atol = 1e-6
104104
if self.dtype == np.float32:
105-
atol = 2e-2
105+
atol = 1e-1
106106

107107
np.testing.assert_allclose(
108108
jnp.array([3/7., 1/7.]),
@@ -242,7 +242,7 @@ def test_truncated_svd_split_preconditioner(self):
242242
("identity", 2.0, 1.0),
243243
("diagonal", 0.2, 0.2),
244244
("rank_one", 0.3, 0.1),
245-
("partial_cholesky", 1e-6, 0.02),
245+
("partial_cholesky", 1e-6, 0.1),
246246
("partial_lanczos", 1e-6, 0.1),
247247
("truncated_svd", 0.2, 0.2),
248248
("truncated_randomized_svd", 0.2, 0.2),
@@ -354,11 +354,11 @@ def test_get_preconditioner_with_kwargs(
354354
("identity", 9000),
355355
("diagonal", 9000),
356356
("rank_one", 3100),
357-
("partial_cholesky", 5.0),
358-
("partial_lanczos", 9000.),
357+
("partial_cholesky", 10.0),
358+
("partial_lanczos", 9000.0),
359359
("truncated_svd", 3100.0),
360360
("truncated_randomized_svd", 3100.0),
361-
("diagonal_split", 9000.),
361+
("diagonal_split", 9000.0),
362362
("rank_one_split", 3100),
363363
# partial_cholesky_split is basically broken until index permutations
364364
# are added to LowRankSplitPreconditioner.

tensorflow_probability/python/math/minimize_test.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -420,9 +420,11 @@ def loss_fn(loc, scale):
420420
final_x, _ = self.evaluate(
421421
minimize_stateless(
422422
loss_fn,
423-
init=NormalParameters(loc=-1., scale=0.1),
423+
init=NormalParameters(loc=np.float32(-1.0), scale=np.float32(0.1)),
424424
num_steps=250,
425-
optimizer=optax.adam(0.1)))
425+
optimizer=optax.adam(0.1),
426+
)
427+
)
426428
# Returned parameters should match `init` structure.
427429
self.assertAllClose(final_x.loc, 0., atol=0.1)
428430
self.assertAllClose(final_x.scale, 1., atol=0.2)

0 commit comments

Comments
 (0)