MCPcopy Create free account
hub / github.com/apache/singa / augmentation

Function augmentation

examples/cnn_ms/train_cnn.py:217–227  ·  view source on GitHub ↗
(x, batch_size)

Source from the content-addressed store, hash-verified

215
216# Data augmentation
217def augmentation(x, batch_size):
218 xpad = np.pad(x, [[0, 0], [0, 0], [4, 4], [4, 4]], 'symmetric')
219 for data_num in range(0, batch_size):
220 offset = np.random.randint(8, size=2)
221 x[data_num, :, :, :] = xpad[data_num, :,
222 offset[0]:offset[0] + x.shape[2],
223 offset[1]:offset[1] + x.shape[2]]
224 if_flip = np.random.randint(2)
225 if (if_flip):
226 x[data_num, :, :, :] = x[data_num, :, :, ::-1]
227 return x
228
229
230# Calculate accuracy

Callers 1

runFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected