(self, x)
| 438 | return z |
| 439 | |
| 440 | def apply_cond_dropout(self, x): |
| 441 | if self.training and self.cond_dropout > 0.: |
| 442 | mask = torch.bernoulli(torch.ones(x.shape[0]) * self.cond_dropout).bool() |
| 443 | if self.uncond.device != x.device: |
| 444 | self.uncond = self.uncond.to(x.device) |
| 445 | x[mask] = self.uncond |
| 446 | return x |
| 447 | |
| 448 | def extract_from_batch(self, batch): |
| 449 | """ |