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

Method testKernelRegularizer

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

Source from the content-addressed store, hash-verified

194
195 @test_util.run_deprecated_v1
196 def testKernelRegularizer(self):
197 regularizer = lambda x: math_ops.reduce_sum(x) * 1e-3
198 dense = core_layers.Dense(
199 2, name='my_dense', kernel_regularizer=regularizer)
200 inputs = random_ops.random_uniform((5, 3), seed=1)
201 _ = dense(inputs)
202 loss_keys = ops.get_collection(ops.GraphKeys.REGULARIZATION_LOSSES)
203 self.assertEqual(len(loss_keys), 1)
204 self.evaluate([v.initializer for v in dense.variables])
205 self.assertAllEqual(self.evaluate(dense.losses), self.evaluate(loss_keys))
206
207 @test_util.run_deprecated_v1
208 def testKernelRegularizerWithReuse(self):

Callers

nothing calls this directly

Calls 6

denseFunction · 0.85
reduce_sumMethod · 0.80
random_uniformMethod · 0.80
get_collectionMethod · 0.45
evaluateMethod · 0.45
assertAllEqualMethod · 0.45

Tested by

no test coverage detected