Compute expected result.
(self, input_image, lrn_depth_radius=5, bias=1.0, alpha=1.0,
beta=0.5)
| 36 | class LRNOpTest(test.TestCase): |
| 37 | |
| 38 | def _LRN(self, input_image, lrn_depth_radius=5, bias=1.0, alpha=1.0, |
| 39 | beta=0.5): |
| 40 | """Compute expected result.""" |
| 41 | output = copy.deepcopy(input_image) |
| 42 | batch_size = input_image.shape[0] |
| 43 | rows = input_image.shape[1] |
| 44 | cols = input_image.shape[2] |
| 45 | depth = input_image.shape[3] |
| 46 | for b in range(batch_size): |
| 47 | for r in range(rows): |
| 48 | for c in range(cols): |
| 49 | for d in range(depth): |
| 50 | begin = max(0, d - lrn_depth_radius) |
| 51 | end = min(depth, d + lrn_depth_radius + 1) |
| 52 | patch = input_image[b, r, c, begin:end] |
| 53 | output[b, r, c, d] /= ( |
| 54 | np.power(bias + alpha * np.sum(patch * patch), beta)) |
| 55 | return output |
| 56 | |
| 57 | def _RunAndVerify(self, dtype): |
| 58 | with self.cached_session(use_gpu=True): |