(x, batch_size)
| 122 | |
| 123 | # Data augmentation |
| 124 | def augmentation(x, batch_size): |
| 125 | xpad = np.pad(x, [[0, 0], [0, 0], [4, 4], [4, 4]], "symmetric") |
| 126 | for data_num in range(0, batch_size): |
| 127 | offset = np.random.randint(8, size=2) |
| 128 | x[data_num, :, :, :] = xpad[ |
| 129 | data_num, :, offset[0]: offset[0] + x.shape[2], offset[1]: offset[1] + x.shape[2] |
| 130 | ] |
| 131 | if_flip = np.random.randint(2) |
| 132 | if if_flip: |
| 133 | x[data_num, :, :, :] = x[data_num, :, :, ::-1] |
| 134 | return x |
| 135 | |
| 136 | |
| 137 | # Calculate accuracy |