STT-tensorflow/tensorflow/python/module
Thomas O'Malley d266494953 Support TF Modules inside Keras Layers and Models.
With this change, it is now possible to mix-and-match tf.keras.Layers and
tf.Modules inside a tf.keras.Model and everything will be tracked properly.

- Variables in tf.Modules that are set as attributes of custom Layers and
  Models now show up properly in properties such as Layer.trainable_variables
  and Model.trainable_variables.
- tf.Modules do not show up in Model.layers. Instead, a new method
  Layer._flatten_modules is added that iterates over tf.Modules and Layers in
  the order that Keras expects. The existing method Layer.submodules (inherited
  from tf.Module) can still be used to iterate over tf.Modules and Layer with the
  tf.Module ordering. Layer._flatten_layers is built on top of
  Layer._flatten_modules
- Layer._layers is renamed to Layer._self_tracked_trackables to avoid naming
  conflicts with user-defined attributes (and to reflect that this attr
  contains Layers, Modules, and TrackableDataStructures)
- A new property is added to tf.Module to enable this, namely
  tf.Module.non_trainable_variables

PiperOrigin-RevId: 339917644
Change-Id: I96a7302745280a6261de8c4295c5cbf5f4d7dd5c
2020-10-30 12:27:12 -07:00
..
BUILD Remove deprecated tfrt_enabled test target flag. 2020-10-22 12:55:06 -07:00
module_test.py Add expand_composite option to tf.Module._flatten to support expanding composite tensors. 2020-10-21 11:47:00 -07:00
module.py Support TF Modules inside Keras Layers and Models. 2020-10-30 12:27:12 -07:00