mirror of
https://github.com/hpcaitech/ColossalAI.git
synced 2025-06-24 06:29:09 +00:00
[NFC] polish colossalai/nn/layer/vanilla/layers.py code style (#1295)
This commit is contained in:
parent
1000a41fd5
commit
e83b2ce853
@ -29,7 +29,7 @@ def drop_path(x, drop_prob: float = 0., training: bool = False):
|
|||||||
if drop_prob == 0. or not training:
|
if drop_prob == 0. or not training:
|
||||||
return x
|
return x
|
||||||
keep_prob = 1 - drop_prob
|
keep_prob = 1 - drop_prob
|
||||||
shape = (x.shape[0], ) + (1, ) * (x.ndim - 1) # work with diff dim tensors, not just 2D ConvNets
|
shape = (x.shape[0],) + (1,) * (x.ndim - 1) # work with diff dim tensors, not just 2D ConvNets
|
||||||
random_tensor = keep_prob + torch.rand(shape, dtype=x.dtype, device=x.device)
|
random_tensor = keep_prob + torch.rand(shape, dtype=x.dtype, device=x.device)
|
||||||
random_tensor.floor_() # binarize
|
random_tensor.floor_() # binarize
|
||||||
output = x.div(keep_prob) * random_tensor
|
output = x.div(keep_prob) * random_tensor
|
||||||
|
Loading…
Reference in New Issue
Block a user