Drop paths (Stochastic Depth) per sample (when applied in main path of residual blocks).
| 160 | |
| 161 | |
| 162 | class DropPath(nn.Module): |
| 163 | """Drop paths (Stochastic Depth) per sample (when applied in main path of residual blocks).""" |
| 164 | |
| 165 | def __init__(self, drop_prob: float = 0.0, scale_by_keep: bool = True): |
| 166 | super(DropPath, self).__init__() |
| 167 | self.drop_prob = drop_prob |
| 168 | self.scale_by_keep = scale_by_keep |
| 169 | |
| 170 | def forward(self, x): |
| 171 | return drop_path(x, self.drop_prob, self.training, self.scale_by_keep) |
| 172 | |
| 173 | def extra_repr(self): |
| 174 | return f"drop_prob={round(self.drop_prob,3):0.3f}" |
| 175 | |
| 176 | |
| 177 | class CaptionEmbedder(nn.Module): |