aboutsummaryrefslogtreecommitdiffhomepage
path: root/tensorflow/python/layers
diff options
context:
space:
mode:
authorGravatar A. Unique TensorFlower <gardener@tensorflow.org>2018-03-06 12:04:06 -0800
committerGravatar TensorFlower Gardener <gardener@tensorflow.org>2018-03-06 12:08:30 -0800
commitcfa4ad28b32dc8a863461efda8fc13d2c8d00724 (patch)
treeb43b1f4cdfa729e9bf0f5d7bfc7a38df9ce1d5c1 /tensorflow/python/layers
parentc8236883db3b53563b24d527aade12e60d5ed246 (diff)
Layers bind to a graph when first called, not at __init__.
PiperOrigin-RevId: 188059096
Diffstat (limited to 'tensorflow/python/layers')
-rw-r--r--tensorflow/python/layers/base_test.py10
1 files changed, 10 insertions, 0 deletions
diff --git a/tensorflow/python/layers/base_test.py b/tensorflow/python/layers/base_test.py
index 91b8988d31..1ee9ec7f7a 100644
--- a/tensorflow/python/layers/base_test.py
+++ b/tensorflow/python/layers/base_test.py
@@ -643,6 +643,16 @@ class BaseLayerTest(test.TestCase):
self.assertEqual(len(layer.get_losses_for([intermediate_inputs])), 1)
self.assertEqual(len(layer.get_losses_for([outputs])), 0)
+ def testLayerGraphSetInFirstApply(self):
+ with ops.Graph().as_default():
+ layer = core_layers.Dense(1) # Graph at construction time is ignored
+ with ops.Graph().as_default():
+ layer.apply(constant_op.constant([[1]]))
+ # layer is now bound to second Graph
+ with ops.Graph().as_default(), self.assertRaisesRegexp(
+ ValueError, 'Input graph and Layer graph are not the same'):
+ layer.apply(constant_op.constant([[1]]))
+
if __name__ == '__main__':
test.main()