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

Function augmentation

examples/hfl/src/client.py:124–134  ·  view source on GitHub ↗
(x, batch_size)

Source from the content-addressed store, hash-verified

122
123# Data augmentation
124def augmentation(x, batch_size):
125 xpad = np.pad(x, [[0, 0], [0, 0], [4, 4], [4, 4]], "symmetric")
126 for data_num in range(0, batch_size):
127 offset = np.random.randint(8, size=2)
128 x[data_num, :, :, :] = xpad[
129 data_num, :, offset[0]: offset[0] + x.shape[2], offset[1]: offset[1] + x.shape[2]
130 ]
131 if_flip = np.random.randint(2)
132 if if_flip:
133 x[data_num, :, :, :] = x[data_num, :, :, ::-1]
134 return x
135
136
137# Calculate accuracy

Callers 1

runFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected