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

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

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