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

Function augmentation

examples/cnn_ms/train_ms_model.py:210–220  ·  view source on GitHub ↗
(x, batch_size)

Source from the content-addressed store, hash-verified

208
209# Data augmentation
210def 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

Callers 1

runFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected