Drop paths (Stochastic Depth) per sample (when applied in main path of residual blocks).
| 426 | |
| 427 | |
| 428 | class DropPath(nn.Module): |
| 429 | """ Drop paths (Stochastic Depth) per sample (when applied in main path of residual blocks). |
| 430 | """ |
| 431 | |
| 432 | def __init__(self, drop_prob=None, scale_by_keep=True): |
| 433 | super(DropPath, self).__init__() |
| 434 | self.drop_prob = drop_prob |
| 435 | self.scale_by_keep = scale_by_keep |
| 436 | |
| 437 | def forward(self, x): |
| 438 | return drop_path(x, self.drop_prob, self.training, self.scale_by_keep) |
| 439 | |
| 440 | |
| 441 | def trunc_normal_(tensor, mean=0., std=1., a=-2., b=2.): |