未验证 提交 c07c5de1 编写于 作者: jm_12138's avatar jm_12138 提交者: GitHub

Fix a bug of DropPath (#575)

上级 30fee0f9
......@@ -42,14 +42,13 @@ def drop_path(x, drop_prob=0., training=False):
"""
if drop_prob == 0. or not training:
return x
keep_prob = 1 - drop_prob
keep_prob = paddle.to_tensor(1 - drop_prob)
shape = (x.shape[0],) + (1,) * (x.ndim - 1)
random_tensor = keep_prob + paddle.rand(shape, dtype=x.dtype)
random_tensor.floor_() # binarize
output = x.div(keep_prob) * random_tensor
random_tensor = paddle.floor(random_tensor) # binarize
output = x.divide(keep_prob) * random_tensor
return output
class DropPath(nn.Layer):
"""Drop paths (Stochastic Depth) per sample (when applied in main path of residual blocks).
"""
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册