MCPcopy
hub / github.com/alibaba/EasyCV / mixUpCls

Function mixUpCls

easycv/utils/preprocess_function.py:197–207  ·  view source on GitHub ↗
(data, alpha=0.2)

Source from the content-addressed store, hash-verified

195
196
197def mixUpCls(data, alpha=0.2):
198 if alpha > 0:
199 lam = np.random.beta(alpha, alpha)
200 else:
201 lam = 1
202
203 batch_size = data.size(0)
204 index = torch.randperm(batch_size, device=data.device)
205 data_mixed = lam * data + (1 - lam) * data[index, :]
206
207 return data_mixed, lam, index
208
209
210if __name__ == '__main__':

Callers

nothing calls this directly

Calls 1

sizeMethod · 0.45

Tested by

no test coverage detected