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

Function augmentation

examples/cnn/train_cnn.py:35–45  ·  view source on GitHub ↗
(x, batch_size)

Source from the content-addressed store, hash-verified

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

Callers 1

runFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected