未验证 提交 1a372bd1 编写于 作者: W Weilong Wu 提交者: GitHub

[Eager, Performance optimization] polish uniform_random (#45807)

上级 87cba48b
......@@ -817,12 +817,14 @@ class MSRAInitializer(Initializer):
if self._uniform:
gain = calculate_gain(self._nonlinearity, self._negative_slope)
limit = gain * math.sqrt(3.0 / float(fan_in))
out_var = _legacy_C_ops.uniform_random('shape', out_var.shape,
'min', -limit, 'max',
limit, 'seed',
self._seed, 'dtype',
int(out_dtype))
if in_dygraph_mode():
out_var = _C_ops.uniform_random(var.shape, out_dtype,
-limit, limit, self._seed,
_current_expected_place())
else:
out_var = _legacy_C_ops.uniform_random(
'shape', out_var.shape, 'min', -limit, 'max', limit,
'seed', self._seed, 'dtype', int(out_dtype))
else:
gain = calculate_gain(self._nonlinearity, self._negative_slope)
std = gain / math.sqrt(float(fan_in))
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册