Function
drop_feature
(x: torch.Tensor, drop_prob: float)
Source from the content-addressed store, hash-verified
| 87 | |
| 88 | |
| 89 | def drop_feature(x: torch.Tensor, drop_prob: float) -> torch.Tensor: |
| 90 | device = x.device |
| 91 | drop_mask = torch.empty((x.size(1),), dtype=torch.float32).uniform_(0, 1) < drop_prob |
| 92 | drop_mask = drop_mask.to(device) |
| 93 | x = x.clone() |
| 94 | x[:, drop_mask] = 0 |
| 95 | |
| 96 | return x |
| 97 | |
| 98 | |
| 99 | def dropout_feature(x: torch.FloatTensor, drop_prob: float) -> torch.FloatTensor: |
Tested by
no test coverage detected