Commit Graph

84 Commits

Author SHA1 Message Date
Christopher Suter
51ec68ae07 Re-enable multinomial_test, no longer flaky.
PiperOrigin-RevId: 309284030
Change-Id: I6805cf3e02fe1bed6016ed68e7233c1aeb1989f8
2020-04-30 13:06:51 -07:00
A. Unique TensorFlower
b3307f90aa Increase the test timeout limit.
PiperOrigin-RevId: 299750351
Change-Id: I2fc127e69bf660884999ffb5e70ba058ab91c15c
2020-03-08 20:26:32 -07:00
Kazuaki Ishizaki
bd8e308b4c minor spelling tweaks 2020-02-11 15:09:21 +09:00
Brian Atkinson
2fcfa6085b Move additional_deps to deps for cuda_py_test.
PiperOrigin-RevId: 285283853
Change-Id: I2534d9fb51955cc9a86d1900ec60fc265f451ddc
2019-12-12 15:28:04 -08:00
Mihai Maruseac
7bdded7cd5 Just some tag change
PiperOrigin-RevId: 281782407
Change-Id: I5893a7286d75138e8392d1b5ef8b974c13a2b4e4
2019-11-21 10:47:37 -08:00
David Majnemer
e5983061d3 [XLA] Implement the regularized incomplete beta function
An implementation involving continued fractions is used. The continued fraction
for this function can be seen at http://dlmf.nist.gov/8.17.v

PiperOrigin-RevId: 277327138
Change-Id: Icb8527af344b629806fd7e4880072d05e2530cd2
2019-10-29 11:45:18 -07:00
Tres Popp
e01699ccbd [TF:XLA] Cleanup cuda_py_test calls with xla_enable_strict_auto_jit = True.
PiperOrigin-RevId: 270858131
2019-09-24 02:07:26 -07:00
Martin Wicke
f7f6f8655a Use "is" instead of ==, and Reference for dict keys {} in Bijector.
PiperOrigin-RevId: 263629253
2019-08-15 13:50:03 -07:00
Amit Patankar
bbdf4709d3 Automated rollback of commit b670c96736
PiperOrigin-RevId: 263605992
2019-08-15 12:10:02 -07:00
A. Unique TensorFlower
208d410d1d Adjust structure of all BUILD files to recommended style (https://docs.bazel.build/versions/master/skylark/build-style.html#file-structure), moving loads to top.
PiperOrigin-RevId: 252573670
2019-06-11 01:56:14 -07:00
A. Unique TensorFlower
278ed897b5 Apply 'buildozer fix moveLicensesAndDistribs movePackageToTop' to all BUILD files.
PiperOrigin-RevId: 249806664
2019-05-24 03:46:12 -07:00
Amit Patankar
b670c96736 Disable a test.
PiperOrigin-RevId: 249604900
2019-05-23 02:20:43 -07:00
Mark Daoust
41d03e186c Apply tf1-tf2 renames to tensorflow/python/kernel_tests docstrings and comments.
No code changes, only doc-strings and comments.

PiperOrigin-RevId: 244372113
2019-04-19 09:54:23 -07:00
A. Unique TensorFlower
bc6db71576 Update test case for use with SciPy 1.2.1.
PiperOrigin-RevId: 239279189
2019-03-19 15:54:02 -07:00
Yanan Cao
b3ee362daa Internal change
PiperOrigin-RevId: 230928112
2019-01-25 10:51:22 -08:00
A. Unique TensorFlower
4ac9bda9d0 [TF:XLA] Enable XLA through autojit for all tensorflow/python/kernel_test/ tests.
Some test methods are disabled, but all tests now have a new "_xla" version of the test for XLA:GPU testing. This will run 2 different tests. One with XLA and one without.

PiperOrigin-RevId: 229149574
2019-01-14 02:42:27 -08:00
Jeremy Lau
105fbe528c Internal change.
PiperOrigin-RevId: 226087680
2018-12-18 17:24:25 -08:00
Gaurav Jain
4890b781b6 Annotate tests as @run_v1_only
Skip individual test cases or entire suites that are not
running in v1. Also replace some @run_deprecated_v1
annotations since simply running the test in graph mode
was not enough.

PiperOrigin-RevId: 224604547
2018-12-07 17:41:47 -08:00
Gaurav Jain
24f578cd66 Add @run_deprecated_v1 annotation to tests failing in v2
PiperOrigin-RevId: 223422907
2018-11-29 15:43:25 -08:00
Gaurav Jain
b17d53c0cd Replace a few calls of Session run with evaluate
In order to support tests running in eager mode we need to avoid
unnecessary use of Sessions in tests. This moves to remove some
of the uses of the `run` function in favor of `evaluate`.

PiperOrigin-RevId: 223009795
2018-11-27 10:09:00 -08:00
Alexandre Passos
f6ce9fd485 Automated rollback of commit 1fdd7c7408
PiperOrigin-RevId: 222434204
2018-11-21 11:14:22 -08:00
Gaurav Jain
1fdd7c7408 Replace a few calls of Session run with evaluate
In order to support tests running in eager mode we need to avoid
unnecessary use of Sessions in tests. This moves to remove some
of the uses of the `run` function in favor of `evaluate`.

PiperOrigin-RevId: 222013881
2018-11-18 20:05:24 -08:00
Gaurav Jain
4fe22bc9da Replace many calls to eval() with self.evaluate()
In order to get tests running in eager mode we need to remove invalid
functions calls such as eval(). This change is simply a search and
replace for tests where this was safe. As a result, a few more tests now
work in eager mode.

PiperOrigin-RevId: 221836866
2018-11-16 13:10:31 -08:00
A. Unique TensorFlower
b94f5bb165 Move from deprecated self.test_session() to self.session() or self.cached_session().
Move to cached_session() if the session is create more than once per test. Move to session() otherwise.

self.test_session() has been deprecated in 9962eb5e84 as its name confuses readers of the test. Moving to session() instead which slightly changes the semantic of the function:
* the session is not cached anymore (a new session is created).
* the session is closed when exiting the "with" scope.

PiperOrigin-RevId: 216868101
2018-10-12 08:48:31 -07:00
A. Unique TensorFlower
0f9baa02a4 Re-enable the arithmetic optimizer by default in tests.
Add a warning to not disable optimizers without consulting with the Grappler team.

PiperOrigin-RevId: 215584369
2018-10-03 10:31:44 -07:00
A. Unique TensorFlower
28757ad658 Use xlogy in a few places in TFP to avoid NaN's for certain special cases.
PiperOrigin-RevId: 215392621
2018-10-02 08:34:53 -07:00
A. Unique TensorFlower
49bbfec04b Override implementation of log survival for Exponential distribution to better handle small values.
PiperOrigin-RevId: 215299532
2018-10-01 16:20:57 -07:00
Brian Patton
72b9279606 Specify a preferred_dtype=self.dtype when converting Distribution methods' sample-like args to Tensors.
After this change, you could conceivably write tfd.Normal(0., 1.).log_prob(1)

The tf core distributions can't use tfp dtype_util.common_dtype, so you can't yet write tfd.Normal(0, 1).

Works around an eager bug that loses precision in the presence in tf.convert_to_tensor(0.5, preferred_dtype=tf.int32)

PiperOrigin-RevId: 214666222
2018-09-26 14:14:46 -07:00
Asim Shankar
ec6ea3ad0a contrib/distributions: Test code cleanups
- Remove unnecessary test_session() boilerplate when executing eagerly
- Use self.cached_session() instead of self.test_session() when using graphs

self.test_session() has been deprecated in 9962eb5e84 as its name confuses readers of the test. Moving to cached_session() instead which is more explicit about:
* the fact that the session may be reused.
* the session is not closed even when doing a "with self.test_session()" statement.

PiperOrigin-RevId: 211542360
2018-09-04 16:12:06 -07:00
Allen Lavoie
d29eb6d1c9 Remove reference cycles when constructing distribution objects
self -> _parameters -> self cycles were creating work for Python's garbage collector in training loops, where Distribution objects may be created repeatedly when executing eagerly. This CL just fixes that narrow memory issue; I'm not convinced dict(locals()) is super efficient, so we may want to follow up on that for performance.

Adds a few unit tests tests with run_test_in_graph_and_eager_modes(assert_no_eager_garbage=True). It'd be nice to expand this coverage over time.

Includes a small test_util simplification to support this (TFP tests don't like reset_default_graph for some reason). Testing for cycles in the TFP repo will need to wait on the Normal changes from the TF repo syncing.

PiperOrigin-RevId: 211520394
2018-09-04 14:26:01 -07:00
A. Unique TensorFlower
0714726b47 Move from deprecated self.test_session() to self.cached_session().
self.test_session() has been deprecated in 9962eb5e84 as its name confuses readers of the test. Moving to cached_session() instead which is more explicit about:
* the fact that the session may be reused.
* the session is not closed even when doing a "with self.test_session()" statement.

PiperOrigin-RevId: 209839030
2018-08-22 15:32:20 -07:00
TensorFlower Gardener
4f4091db6d Merge pull request from luk-ai:cast-quantized
PiperOrigin-RevId: 205881436
2018-07-24 13:38:33 -07:00
Tristan Rice
1107fb0183
Cast: support casting to and from quantized types 2018-07-06 13:19:38 -07:00
A. Unique TensorFlower
b894f6844a Gamma distribution and the derived distributions (Beta, Dirichlet, Student's t, inverse Gamma) are fully reparameterized.
For every distribution, the changes are:
* Set reparameterization_type to FULLY_REPARAMETERIZED.
* Add a note about reparameterization and an example to the docstring.
* Add a test that ensures that the gradients exist.

Additional changes:
* Fix docstring and test in TFP that assume that Gamma is not reparameterized. We simply replace Gamma with Bernoulli :)
* Fix paths to modules in docstrings.

PiperOrigin-RevId: 201691205
2018-06-22 08:53:31 -07:00
A. Unique TensorFlower
18921a5d96 Reduce flakiness of tf.distributions tests by tweaking the tolerances.
tf.distributions.DirichletMultinomial test was flaky.

PiperOrigin-RevId: 201685575
2018-06-22 08:05:24 -07:00
Tom Hennigan
945d1a77ae Replace unnecessary () in run_in_graph_and_eager_modes().
PiperOrigin-RevId: 201652888
2018-06-22 01:49:29 -07:00
A. Unique TensorFlower
7e510ff751 Update Eigen version to commit e5e305a158a029f5b5f837bf821411a51439a970.
PiperOrigin-RevId: 201624024
2018-06-21 18:57:41 -07:00
A. Unique TensorFlower
6cf61a02e1 Run tests for tf.distributions.Gamma in both graph and eager modes.
PiperOrigin-RevId: 201539026
2018-06-21 09:44:53 -07:00
A. Unique TensorFlower
bead8aaf6c Disable guitar dirichlet_multinomial_test_gpu
PiperOrigin-RevId: 201534842
2018-06-21 09:15:42 -07:00
A. Unique TensorFlower
dfbdc142e6 Add tests for the reparameterization_type of tf.distributions.
Take samples from the distribution and differentiate the samples wrt the parameters. If the distribution is not reparameterized, the gradients should be None. Otherwise, they should not be None.

PiperOrigin-RevId: 201502156
2018-06-21 03:52:38 -07:00
A. Unique TensorFlower
d9774ba1cd Disable flaky dirichlet_multinomial_test_gpu
PiperOrigin-RevId: 201440233
2018-06-20 16:48:27 -07:00
A. Unique TensorFlower
3fa0009cbd Replace distribution_util.assert_close with tf.assert_near.
PiperOrigin-RevId: 201058937
2018-06-18 14:31:45 -07:00
Christopher Suter
d943de372a Support non-static shape in tf.distributions.Categorical.
PiperOrigin-RevId: 200596358
2018-06-14 12:11:47 -07:00
Joshua V. Dillon
176754d6cc Add fill_triangular_inverse, which flattens a triangular matrix in a way such that:
# Lower triangular matrix
x = tf.matrix_band_part(x, -1, 0)
x == fill_triangular(fill_triangular_inverse(x))
Code by srvasude@ which I'm submitting on his behalf.

PiperOrigin-RevId: 198623887
2018-05-30 14:55:47 -07:00
A. Unique TensorFlower
5eb5109940 KL divergence for two Dirichlet distributions.
PiperOrigin-RevId: 198573236
2018-05-30 09:42:43 -07:00
Yifei Feng
b59833c3fd Merge changes from github.
Revert . Too many internal test failures due to the name scope change caused by this change.
Revert . Cannot use re2::StringPiece internally. Need alternative for set call. Will pull and clean this up in a separate change.

PiperOrigin-RevId: 197991247
2018-05-24 19:15:01 -07:00
A. Unique TensorFlower
42e50daa38 Set the correct shape in transformed distribution.
Also add distribution_util.maybe_get_static_event_ndims to be reused in bijector and transformed distribution classes.

PiperOrigin-RevId: 197831651
2018-05-23 20:05:39 -07:00
Akshay Modi
01dbc6ac45 Test some distributions stuff in Eager as well as Graph
PiperOrigin-RevId: 197033485
2018-05-17 12:33:50 -07:00
Skye Wanderman-Milne
0c33e1ff58 Remove _USE_C_API staging in tests now that the C API is enabled by default.
This is in preparation for removing the _USE_C_API toggle altogether.

PiperOrigin-RevId: 196920481
2018-05-16 18:06:14 -07:00
Joshua V. Dillon
d0f396bb89 BUGFIX: correctly propagate dtype in distributions.special_math.
PiperOrigin-RevId: 196155994
2018-05-10 12:43:19 -07:00