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

Method testCreateBN

tensorflow/python/layers/normalization_test.py:260–284  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

258 self._testCheckpointCrossDevice(False, False, True, False)
259
260 def testCreateBN(self):
261 # Call layer.
262 bn = normalization_layers.BatchNormalization(axis=1)
263 inputs = random_ops.random_uniform((5, 4, 3), seed=1)
264 training = array_ops.placeholder(dtype='bool')
265 outputs = bn.apply(inputs, training=training)
266
267 # Verify shape.
268 self.assertListEqual(outputs.get_shape().as_list(), [5, 4, 3])
269
270 # Verify layer attributes.
271 self.assertEqual(len(bn.updates), 2)
272 self.assertEqual(len(bn.variables), 4)
273 self.assertEqual(len(bn.trainable_variables), 2)
274 self.assertEqual(len(bn.non_trainable_variables), 2)
275
276 # Test that updates were created and added to UPDATE_OPS.
277 self.assertEqual(len(bn.updates), 2)
278 self.assertListEqual(
279 ops.get_collection(ops.GraphKeys.UPDATE_OPS), bn.updates)
280
281 # Test that weights were created and added to TRAINABLE_VARIABLES.
282 self.assertListEqual(
283 ops.get_collection(ops.GraphKeys.TRAINABLE_VARIABLES),
284 bn.trainable_variables)
285
286 def testCreateFusedBNFloat16(self):
287 # Call layer.

Callers

nothing calls this directly

Calls 6

random_uniformMethod · 0.80
placeholderMethod · 0.45
applyMethod · 0.45
as_listMethod · 0.45
get_shapeMethod · 0.45
get_collectionMethod · 0.45

Tested by

no test coverage detected