MCPcopy Create free account
hub / github.com/Ropedia/SpatialBench / drop_path

Function drop_path

benchmark/models/zipmap/zipmap/layers/drop_path.py:9–18  ·  view source on GitHub ↗
(x, drop_prob: float = 0.0, training: bool = False)

Source from the content-addressed store, hash-verified

7
8
9def drop_path(x, drop_prob: float = 0.0, training: bool = False):
10 if drop_prob == 0.0 or not training:
11 return x
12 keep_prob = 1 - drop_prob
13 shape = (x.shape[0],) + (1,) * (x.ndim - 1) # work with diff dim tensors, not just 2D ConvNets
14 random_tensor = x.new_empty(shape).bernoulli_(keep_prob)
15 if keep_prob > 0.0:
16 random_tensor.div_(keep_prob)
17 output = x * random_tensor
18 return output
19
20
21class DropPath(nn.Module):

Callers 1

forwardMethod · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected