MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / testDeepCopy

Method testDeepCopy

tensorflow/python/layers/base_test.py:196–215  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

194
195 @test_util.run_in_graph_and_eager_modes
196 def testDeepCopy(self):
197
198 class MyLayer(base_layers.Layer):
199
200 def call(self, inputs):
201 return math_ops.square(inputs)
202
203 layer = MyLayer(name='my_layer')
204 layer._private_tensor = random_ops.random_uniform(())
205 inputs = random_ops.random_uniform((5,), seed=1)
206 outputs = layer.apply(inputs)
207 self.assertEqual(layer.built, True)
208 if not context.executing_eagerly():
209 # op only supported in GRAPH mode.
210 self.assertEqual(outputs.op.name, 'my_layer/Square')
211
212 layer_copy = copy.deepcopy(layer)
213 self.assertEqual(layer_copy.name, layer.name)
214 self.assertEqual(layer_copy._scope.name, layer._scope.name)
215 self.assertEqual(layer_copy._private_tensor, layer._private_tensor)
216
217 @test_util.run_in_graph_and_eager_modes
218 def testScopeNaming(self):

Callers

nothing calls this directly

Calls 4

random_uniformMethod · 0.80
executing_eagerlyMethod · 0.80
MyLayerClass · 0.70
applyMethod · 0.45

Tested by

no test coverage detected