Tomer Kaftan aac1dd5788 Updates Keras layer __call__ to always set training, with the following priority order:
# Training mode for `Layer.__call__` is set via (in order of priority):
    # (1) The `training` argument passed to this `Layer.__call__`, if it is not None
    # (2) The training mode of an outer `Layer.__call__`.
    # (3) The default mode set by `tf.keras.backed.set_learning_phase` (if set).
    # (4) Any non-None default value for `training` specified in the `call`
    #  signature
    # (5) False (treating the layer as if it's in inference)

Previously (4) and (5) were missing, leading to crashes for layers that do not provide a default argument for `training`.

Note that (4) is fragile to reflection issues, and may get confused by decorators.

PiperOrigin-RevId: 317709904
Change-Id: I58039a4d9e5106bcb27f4cfbf65e6762f1b40807
2020-06-22 13:13:46 -07:00
..