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

Method testLrnGrad

tensorflow/compiler/tests/lrn_ops_test.py:101–125  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

99 self._RunAndVerify(dtypes.float32)
100
101 def testLrnGrad(self):
102 # Test for LRNGrad that compares against the CPU implementation.
103 shape = [1, 2, 3, 4]
104 total_size = np.prod(shape)
105 in_image_vals = np.arange(1, total_size + 1, dtype=np.float32)
106 out_image_vals = np.arange(1, total_size + 1, dtype=np.float32)
107 out_grads_vals = np.arange(1, total_size + 1, dtype=np.float32)
108 depth_radius = np.random.randint(1, shape[3])
109 bias = 1.0 + np.random.rand()
110 alpha = 1.0 * np.random.rand()
111 beta = 1.0 * np.random.rand()
112
113 with self.session():
114 in_image = constant_op.constant(in_image_vals, shape=shape)
115 out_image = constant_op.constant(out_image_vals, shape=shape)
116 out_grads = constant_op.constant(out_grads_vals, shape=shape)
117 with ops.device(CPU_DEVICE):
118 expected = gen_nn_ops.lrn_grad(out_grads, in_image, out_image,
119 depth_radius, bias, alpha, beta)
120 with self.test_scope():
121 actual = gen_nn_ops.lrn_grad(out_grads, in_image, out_image,
122 depth_radius, bias, alpha, beta)
123 expected_val = self.evaluate(expected)
124 actual_val = self.evaluate(actual)
125 self.assertAllClose(actual_val, expected_val, rtol=1e-3)
126
127
128if __name__ == "__main__":

Callers

nothing calls this directly

Calls 7

randMethod · 0.80
sessionMethod · 0.45
constantMethod · 0.45
deviceMethod · 0.45
test_scopeMethod · 0.45
evaluateMethod · 0.45
assertAllCloseMethod · 0.45

Tested by

no test coverage detected