(x, batch_size)
| 34 | |
| 35 | # Data augmentation |
| 36 | def augmentation(x, batch_size): |
| 37 | xpad = np.pad(x, [[0, 0], [0, 0], [4, 4], [4, 4]], 'symmetric') |
| 38 | for data_num in range(0, batch_size): |
| 39 | offset = np.random.randint(8, size=2) |
| 40 | x[data_num, :, :, :] = xpad[data_num, :, |
| 41 | offset[0]:offset[0] + x.shape[2], |
| 42 | offset[1]:offset[1] + x.shape[2]] |
| 43 | if_flip = np.random.randint(2) |
| 44 | if (if_flip): |
| 45 | x[data_num, :, :, :] = x[data_num, :, :, ::-1] |
| 46 | return x |
| 47 | |
| 48 | |
| 49 | # Calculate accuracy |