Commit Graph

31 Commits

Author SHA1 Message Date
Scott Zhu
86db575653 Fork the run_v2_only annotation to keras, and remove the usage of one in TF.
PiperOrigin-RevId: 329805357
Change-Id: Iea6dfe514abbb880a6693b857c2f22367b0b94bf
2020-09-02 16:00:59 -07:00
Scott Zhu
3ab25c3203 Fix RNN cell wrt deep copy.
The root cause is that we have some internal cache field, which is not picklable by python.

Fix https://github.com/tensorflow/tensorflow/issues/39978.

PiperOrigin-RevId: 314265192
Change-Id: I66e80dea5fb65ac9c2e567f2af74510cd64ce5fc
2020-06-01 21:56:22 -07:00
Reed Wanderman-Milne
b7014702fd Remove passing experimental_run_tf_function in most tests.
The experimental_run_tf_function parameter no longer has any effect.

I didn't remove the functionality from testing_util.py and keras_parameterized.py to run with experimental_run_tf_function being True and False. I will remove that functionality in a future change.

PiperOrigin-RevId: 297674422
Change-Id: I5b1e67f78b4c3b60242241fb4dc2018f0ace6013
2020-02-27 13:34:09 -08:00
TensorFlower Gardener
59d2ac77e4 Merge pull request from ROCmSoftwarePlatform:rocm-gru-lstm
PiperOrigin-RevId: 295248028
Change-Id: I5c06506fd5724d45791aeac1065de96e4e1a6a08
2020-02-14 16:17:19 -08:00
Deven Desai
5f8828b16e fixing pylint errors 2020-02-10 21:13:49 +00:00
Deven Desai
f026e707d3 Skipping unsupported subtests within the tests lstm_test and gru_test 2020-02-10 20:46:24 +00:00
A. Unique TensorFlower
83569dfad9 Removes two Keras fallbacks to older v1 code:
1. when calling predict without compiling first.
2. when using a tf.compat.v1.optimizers.Optimizer (these work eagerly & should work in the v2 loops)

This revealed some missing coverage in the tests & a few bugs.

The fixes to these issues are are:
1. Int sample weights used with masks now work correctly (w/o type crashes)
2. Keras in TF2 explicitly disallows using sparse scipy matrices as inputs to dense functional model inputs. A meaningful error is now raised whereas before this crashed w/ unclear messages. In v1 the scipy matrices were silently cast to dense arrays, but this causes ambiguity for subclass models & can't be done w/o too much extra complexity for the data adapters.
3. This cl needs to mark a few tests that depend on v2 dtype behavior as run_v2_only, and changes a few tests to v1_deprecated

PiperOrigin-RevId: 277148078
Change-Id: Ic794104d85f999f0b449cc606df85f1e4cc5b8ed
2019-10-28 16:07:39 -07:00
Mihai Maruseac
f3731576e7 Roolback of 268229dfed
PiperOrigin-RevId: 276513946
Change-Id: Idb7f04f12f462bc5f17e5928de686ed251138553
2019-10-24 10:23:43 -07:00
A. Unique TensorFlower
268229dfed Removes two Keras fallbacks to older v1 code:
1. when calling predict without compiling first.
2. when using a tf.compat.v1.optimizers.Optimizer (these work eagerly & should work in the v2 loops)

This revealed some missing coverage in the tests & a few bugs.

The fixes to these issues are are:
1. Int sample weights used with masks now work correctly (w/o type crashes)
2. Keras in TF2 explicitly disallows using sparse scipy matrices as inputs to dense functional model inputs. A meaningful error is now raised whereas before this crashed w/ unclear messages. In v1 the scipy matrices were silently cast to dense arrays, but this causes ambiguity for subclass models & can't be done w/o too much extra complexity for the data adapters.
3. This cl needs to mark a few tests that depend on v2 dtype behavior as run_v2_only, and changes a few tests to v1_deprecated

PiperOrigin-RevId: 276388163
Change-Id: I0c31e4e6aa16793f119f6f0184a93b294db3d030
2019-10-23 18:08:06 -07:00
Scott Zhu
9002ff156e Force the LSTM/GRU cell to run with implementation 1 when
recurrent_dropout is enabled.

This is raised by https://github.com/tensorflow/tensorflow/issues/32987.

In short, implementation 2 was applying one dropout mask to the
recurrent state, rather than having different mask for different gates.
Updating the implementation 2 to dropout on individual gates might make
it very similar as 1, which is why we fallback 1 when recurrent_dropout
is enabled.

PiperOrigin-RevId: 275336490
Change-Id: Ib853339b1033cb4d7c343e8adb349fa9a573fdd3
2019-10-17 14:23:07 -07:00
Scott Zhu
4d01179307 Update backend.rnn() to support unroll and masking with nested states.
1. Change the assertion to be ValueError for better stacktrace and error
context.
2. Adding slight comment for rnn() since the body of it too long.



PiperOrigin-RevId: 271199425
2019-09-25 14:16:57 -07:00
Yanhua Sun
ddf9999ce2 Fix assert a in b in lstm with assertTrue (any( a is b))
PiperOrigin-RevId: 263473895
2019-08-14 18:51:59 -07:00
Reed Wanderman-Milne
d90e521d71 Have RNN classes pass their dtypes to their cells.
In TF 2, this makes RNNs work properly when a non-float32 dtype is passed to them. ConvLSTM2D is still broken with non-float32 dtypes however, as it calls tf.zeros() in various places without passing the correct dtype.

PiperOrigin-RevId: 261368927
2019-08-02 13:04:59 -07:00
Pavithra Vijay
c7933ce9f3 Renames the run_distributed flag to experimental_run_tf_function and modifies the tests generated by the keras_all_modes decorator to better reflect that.
PiperOrigin-RevId: 260767064
2019-07-30 13:29:22 -07:00
Scott Zhu
59217f581f Enable all keras tests with run_distributed=True.
Failed tests are all disabled for now, and we should address them while we updating the v2 training path and util functions.

PiperOrigin-RevId: 258267130
2019-07-15 17:12:14 -07:00
Amit Srivastava
b445b1c6f3 Replaced get_shape() to shape.
This is the recommended method.
2019-03-17 08:08:39 +05:30
Zhenyu Tan
104c9dac9c replace keras.optimizers with keras v2 optimizer in 1.0.
PiperOrigin-RevId: 228905734
2019-01-11 10:52:33 -08:00
Scott Zhu
a460c9525d Fix masking generate logic in sequence model.
sequence model was incorrectly using the layer output instead of input to generate mask, and compute_mask of the layer usually does not have shape check.

PiperOrigin-RevId: 227605298
2019-01-02 17:03:30 -08:00
Scott Zhu
a15adadb7c Test case cleanup.
PiperOrigin-RevId: 226540622
2018-12-21 14:19:53 -08:00
Gaurav Jain
f5ef72147c Downgrade some @run_v1_only annotations
Some annotations were too coarse grained, whereas others were resolved
with recent fixes.

PiperOrigin-RevId: 225455888
2018-12-13 16:31:09 -08:00
Scott Zhu
4637671e4e Enable v2 mode for lstm_test.
Test that can only run in v1 has the proper bug attached.

PiperOrigin-RevId: 225291768
2018-12-12 18:17:49 -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
Scott Zhu
64d96c3df5 Replace deprecated method assertEquals() to assertEqual() in all keras py tests.
PiperOrigin-RevId: 223844581
2018-12-03 12:58:01 -08:00
Scott Zhu
97ffac50fe Split the flaky test_implementation_mode into 3 tests.
This test case usually took too long to execute, and cause that test shard to time out. Use paramsterized test so that each implementation mode are now split into separate test case.

PiperOrigin-RevId: 223815273
2018-12-03 10:29:20 -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
Scott Zhu
149886979a Update RNN backend for masking of outputs.
The existing logic assumes the state[0] of the step function is same as the
output, which is not necessary true anymore. Update the logic to read the
outputs from the previous steps.

PiperOrigin-RevId: 220816333
2018-11-09 09:44:42 -08:00
A. Unique TensorFlower
6f7cbd60a2 Makes a number of Keras layer tests run in both graph and eager modes.
PiperOrigin-RevId: 217422423
2018-10-16 18:15:41 -07:00
A. Unique TensorFlower
acf0ee8209 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: 212336417
2018-09-10 15:01:47 -07:00
Francois Chollet
3ae2df156f Enable masking support for eager execution.
PiperOrigin-RevId: 207016849
2018-08-01 16:45:21 -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
Pavithra Vijay
609b2ce3fe Move Keras code out of _impl folder and remove API files.
PiperOrigin-RevId: 197097430
2018-05-17 21:40:10 -07:00