manually process each sample with per sample gradient
(data, targets)
| 89 | |
| 90 | |
| 91 | def compute_sample_grads(data, targets): |
| 92 | """ manually process each sample with per sample gradient """ |
| 93 | sample_grads = [compute_grad(data[i], targets[i]) for i in range(batch_size)] |
| 94 | sample_grads = zip(*sample_grads) |
| 95 | sample_grads = [torch.stack(shards) for shards in sample_grads] |
| 96 | return sample_grads |
| 97 | |
| 98 | per_sample_grads = compute_sample_grads(data, targets) |
| 99 |
no test coverage detected