megengine.functional.nn.local_response_norm¶
- local_response_norm(inp, kernel_size=5, k=2.0, alpha=0.0001, beta=0.75)[源代码]¶
对输入 Tensor 进行局部响应归一化。
- 参数
例如:
from megengine import tensor import megengine.functional as f import numpy as np inp = tensor(np.arange(25, dtype=np.float32).reshape(1,1,5,5)) GT = np.array([[[[ 0., 0.999925, 1.9994003, 2.9979765, 3.9952066], [ 4.9906454, 5.983851, 6.974385, 7.961814, 8.945709 ], [ 9.925651, 10.90122, 11.872011, 12.837625, 13.7976675], [14.751757, 15.699524, 16.640602, 17.574642, 18.501305 ], [19.420258, 20.331186, 21.233786, 22.127764, 23.012836 ]]]]) out = f.local_response_norm(inp, kernel_size=3, k=1.0, alpha=1e-4, beta=0.75) np.testing.assert_allclose(GT, out.numpy(), rtol=1e-6, atol=1e-6) print('pass')
输出:
pass
- 返回类型