Drop paths (Stochastic Depth) per sample (when applied in main path of residual blocks).
| 22 | |
| 23 | |
| 24 | class DropPath(torch.nn.Module): |
| 25 | """Drop paths (Stochastic Depth) per sample (when applied in main path of residual blocks). |
| 26 | """ |
| 27 | def __init__(self, drop_prob: float = 0., scale_by_keep: bool = True): |
| 28 | super(DropPath, self).__init__() |
| 29 | self.drop_prob = drop_prob |
| 30 | self.scale_by_keep = scale_by_keep |
| 31 | |
| 32 | def forward(self, x): |
| 33 | return drop_path(x, self.drop_prob, self.training, self.scale_by_keep) |
| 34 | |
| 35 | def extra_repr(self): |
| 36 | return f'drop_prob={round(self.drop_prob,3):0.3f}' |