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

Function augmentation

examples/singa_peft/examples/train.py:36–46  ·  view source on GitHub ↗
(x, batch_size)

Source from the content-addressed store, hash-verified

34
35# Data augmentation
36def 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

Callers 2

runFunction · 0.70
peftFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected