diff options
author | Reed Wanderman-Milne <reedwm@google.com> | 2018-06-19 10:57:50 -0700 |
---|---|---|
committer | TensorFlower Gardener <gardener@tensorflow.org> | 2018-06-19 11:00:57 -0700 |
commit | d2385b23b96741d34cb14f2e5e092a5d5a754d1f (patch) | |
tree | 04c1be7ad9acc848c3c9dae980162c9548f8184d /tensorflow/python/layers | |
parent | bed3fcdc02409a823e498fcac88d8bf7a3789657 (diff) |
Automated g4 rollback of changelist 200783477
PiperOrigin-RevId: 201204573
Diffstat (limited to 'tensorflow/python/layers')
-rw-r--r-- | tensorflow/python/layers/base.py | 10 | ||||
-rw-r--r-- | tensorflow/python/layers/base_test.py | 62 |
2 files changed, 4 insertions, 68 deletions
diff --git a/tensorflow/python/layers/base.py b/tensorflow/python/layers/base.py index abbe9d0c56..b8969a41ab 100644 --- a/tensorflow/python/layers/base.py +++ b/tensorflow/python/layers/base.py @@ -43,15 +43,13 @@ class Layer(base_layer.Layer): Arguments: trainable: Boolean, whether the layer's variables should be trainable. name: String name of the layer. - dtype: Default dtype of the layer's weights and computations (default of - `None` means use the type of the first input). If not None, inputs will be - casted to this dtype. + dtype: Default dtype of the layer's weights (default of `None` means use the + type of the first input). Read-only properties: name: The name of the layer (string). - dtype: Default dtype of the layer's weights and computations. (default of - `None` means use the type of the first input). If not None, inputs will be - casted to this dtype. + dtype: Default dtype of the layer's weights (default of `None` means use the + type of the first input). trainable_variables: List of trainable variables. non_trainable_variables: List of non-trainable variables. variables: List of all variables of this layer, trainable and diff --git a/tensorflow/python/layers/base_test.py b/tensorflow/python/layers/base_test.py index ad44328aab..fcacc8d603 100644 --- a/tensorflow/python/layers/base_test.py +++ b/tensorflow/python/layers/base_test.py @@ -25,8 +25,6 @@ from tensorflow.python.framework import constant_op from tensorflow.python.framework import dtypes from tensorflow.python.framework import ops from tensorflow.python.framework import test_util -from tensorflow.python.keras import backend -from tensorflow.python.keras.engine import base_layer as keras_base_layer from tensorflow.python.layers import base as base_layers from tensorflow.python.layers import core as core_layers from tensorflow.python.ops import array_ops @@ -591,65 +589,5 @@ class BaseLayerTest(test.TestCase): ValueError, 'Input graph and Layer graph are not the same'): layer.apply(constant_op.constant([[1.]])) - @test_util.run_in_graph_and_eager_modes() - def testOnlyCastInputsWhenDtypeSpecified(self): - - class MyKerasLayer(keras_base_layer.Layer): - - def call(self, inputs): - self.x = inputs[0] - self.y = inputs[1] - return self.x + 1, self.y + 2 - - # Inherit from both the Keras Layer and base_layers.Layer to ensure we - # still get the base_layers.Layer behavior when directly inheriting from - # the Keras Layer. - class MyTFLayer(MyKerasLayer, base_layers.Layer): - pass - - # Test inputs are casted. - input1 = array_ops.constant(1.0, dtype=dtypes.float64) - input2 = array_ops.constant(1.0, dtype=dtypes.float32) - layer = MyTFLayer(dtype=dtypes.float16) - output1, output2 = layer([input1, input2]) - self.assertEqual(output1.dtype, dtypes.float16) - self.assertEqual(output2.dtype, dtypes.float16) - - # Test inputs are not casted. - input1 = array_ops.constant(1.0, dtype=dtypes.float64) - input2 = array_ops.constant(1.0, dtype=dtypes.float32) - layer = MyTFLayer() - output1, output2 = layer([input1, input2]) - self.assertEqual(output1.dtype, dtypes.float64) - self.assertEqual(output2.dtype, dtypes.float32) - - @test_util.run_in_graph_and_eager_modes() - def testVariablesDefaultToFloat32(self): - - class MyKerasLayer(keras_base_layer.Layer): - - def build(self, input_shape): - self.x = self.add_weight('x', ()) - - def call(self, inputs): - return inputs + self.x - - # Inherit from both the Keras Layer and base_layers.Layer to ensure we - # still get the base_layers.Layer behavior when directly inheriting from - # the Keras Layer. - class MyTFLayer(MyKerasLayer, base_layers.Layer): - pass - - try: - # The behavior of Keras Layers is to default to floatx. Ensure that this - # behavior is overridden to instead default to float32. - backend.set_floatx('float16') - layer = MyTFLayer() - layer.build(()) - self.assertEqual(layer.dtype, None) - self.assertEqual(layer.x.dtype.base_dtype, dtypes.float32) - finally: - backend.set_floatx('float32') - if __name__ == '__main__': test.main() |