Allow positional arguments in tf.keras.Model subclasses
authorAllen Lavoie <allenl@google.com>
Wed, 28 Mar 2018 17:03:06 +0000 (10:03 -0700)
committerTensorFlower Gardener <gardener@tensorflow.org>
Wed, 28 Mar 2018 17:05:24 +0000 (10:05 -0700)
commit5a213116df09c19c3ee0eecb5fc79444e5671e80
treebec028a2db003cc632913321fe70a50f8afdbc21
parent119ed5aa2acb6df04595835f6dfa99f5422449f2
Allow positional arguments in tf.keras.Model subclasses

Makes the tf.keras.Layer.__call__ signature identical to tf.layers.Layer.__call__, but makes passing positional arguments other than "inputs" an error in most cases. The only case it's allowed is subclassed Models which do not have an "inputs" argument to their call() method.

This means subclassed Models no longer need to pass all but the first argument as a keyword argument (or do list packing/unpacking) when call() takes multiple Tensor arguments.

Includes errors for cases where whether an argument indicates an input is ambiguous, but otherwise doesn't do much to support non-"inputs" call() signatures for shape inference or deferred Tensors. The definition of an input/non-input is pretty clear, so that cleanup will mostly be tracking down all of the users of "self.call" and getting them to pass inputs as positional arguments if necessary.

PiperOrigin-RevId: 190787899
tensorflow/contrib/eager/python/examples/spinn/spinn_test.py
tensorflow/python/keras/_impl/keras/engine/base_layer.py
tensorflow/python/keras/_impl/keras/engine/network.py
tensorflow/python/keras/_impl/keras/engine/training.py
tensorflow/python/keras/_impl/keras/model_subclassing_test.py
tensorflow/python/layers/base.py
third_party/examples/eager/spinn/spinn.py