| 332 | # interest to relax this relation. For example, consider the following implementation |
| 333 | # of a randomized pruning method: |
| 334 | class PruningParametrization(nn.Module): |
| 335 | def __init__(self, X, p_drop=0.2): |
| 336 | super().__init__() |
| 337 | # sample zeros with probability p_drop |
| 338 | mask = torch.full_like(X, 1.0 - p_drop) |
| 339 | self.mask = torch.bernoulli(mask) |
| 340 | |
| 341 | def forward(self, X): |
| 342 | return X * self.mask |
| 343 | |
| 344 | def right_inverse(self, A): |
| 345 | return A |
| 346 | |
| 347 | ############################################################################### |
| 348 | # In this case, it is not true that for every matrix A ``forward(right_inverse(A)) == A``. |