aboutsummaryrefslogtreecommitdiffhomepage
path: root/tensorflow/python/layers
diff options
context:
space:
mode:
authorGravatar Allen Lavoie <allenl@google.com>2018-03-28 10:03:06 -0700
committerGravatar TensorFlower Gardener <gardener@tensorflow.org>2018-03-28 10:05:24 -0700
commit5a213116df09c19c3ee0eecb5fc79444e5671e80 (patch)
treebec028a2db003cc632913321fe70a50f8afdbc21 /tensorflow/python/layers
parent119ed5aa2acb6df04595835f6dfa99f5422449f2 (diff)
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
Diffstat (limited to 'tensorflow/python/layers')
-rw-r--r--tensorflow/python/layers/base.py2
1 files changed, 2 insertions, 0 deletions
diff --git a/tensorflow/python/layers/base.py b/tensorflow/python/layers/base.py
index 1e5f26a77f..242cdff6f3 100644
--- a/tensorflow/python/layers/base.py
+++ b/tensorflow/python/layers/base.py
@@ -625,6 +625,8 @@ class Layer(checkpointable.CheckpointableBase):
input_list = nest.flatten(inputs)
build_graph = not context.executing_eagerly()
+ # TODO(fchollet, allenl): Make deferred mode work with subclassed Models
+ # which don't use an "inputs" argument.
in_deferred_mode = isinstance(input_list[0], _DeferredTensor)
# Ensure the Layer, if being reused, is working with inputs from
# the same graph as where it was created.