(
self,
prob: float = 0.5,
exclude_first_token: bool = True
)
| 33 | """ |
| 34 | |
| 35 | def __init__( |
| 36 | self, |
| 37 | prob: float = 0.5, |
| 38 | exclude_first_token: bool = True |
| 39 | ): |
| 40 | super().__init__() |
| 41 | assert 0 <= prob < 1. |
| 42 | self.prob = prob |
| 43 | self.exclude_first_token = exclude_first_token # exclude CLS token |
| 44 | |
| 45 | def forward(self, x): |
| 46 | if not self.training or self.prob == 0.: |