Split data for meta update steps and other defenses.
(inputs, labels, p=0.75)
| 99 | |
| 100 | |
| 101 | def _split_data(inputs, labels, p=0.75): |
| 102 | """Split data for meta update steps and other defenses.""" |
| 103 | batch_size = inputs.shape[0] |
| 104 | p_actual = int(p * batch_size) |
| 105 | |
| 106 | inputs, temp_targets, = inputs[0:p_actual], inputs[p_actual:] |
| 107 | labels, temp_true_labels = labels[0:p_actual], labels[p_actual:] |
| 108 | temp_fake_label = labels.mode(keepdim=True)[0].repeat(batch_size - p_actual) |
| 109 | return temp_targets, inputs, temp_true_labels, labels, temp_fake_label |