(x, batch_size)
| 208 | |
| 209 | # Data augmentation |
| 210 | def augmentation(x, batch_size): |
| 211 | xpad = np.pad(x, [[0, 0], [0, 0], [4, 4], [4, 4]], 'symmetric') |
| 212 | for data_num in range(0, batch_size): |
| 213 | offset = np.random.randint(8, size=2) |
| 214 | x[data_num, :, :, :] = xpad[data_num, :, |
| 215 | offset[0]:offset[0] + x.shape[2], |
| 216 | offset[1]:offset[1] + x.shape[2]] |
| 217 | if_flip = np.random.randint(2) |
| 218 | if (if_flip): |
| 219 | x[data_num, :, :, :] = x[data_num, :, :, ::-1] |
| 220 | return x |
| 221 | |
| 222 | |
| 223 | # Calculate accuracy |