code
stringlengths
3
6.57k
torch.tensor([3])
test_invalid_param_combinations(self, bits, device, dtype)
pytest.raises(Exception)
bits.to(device=device, dtype=dtype)
test_random_gen(self, device, dtype)
torch.manual_seed(9)
torch.tensor([0, 8], device=device, dtype=dtype)
dict(bits_factor=torch.tensor([5, 2, 3, 6, 7, 7, 2, 7], device=device, dtype=torch.int32)
res.keys()
expected.keys()
assert_allclose(res['bits_factor'], expected['bits_factor'], rtol=1e-4, atol=1e-4)
test_same_on_batch(self, device, dtype)
torch.manual_seed(9)
torch.tensor([0, 8], device=device, dtype=dtype)
dict(bits_factor=torch.tensor([5, 5, 5, 5, 5, 5, 5, 5], device=device, dtype=torch.int32)
res.keys()
expected.keys()
assert_allclose(res['bits_factor'], expected['bits_factor'], rtol=1e-4, atol=1e-4)
TestRandomSharpnessGen(RandomGeneratorBaseTests)
pytest.mark.parametrize('batch_size', [0, 1, 8])
pytest.mark.parametrize('sharpness', [torch.tensor([0., 1.])
pytest.mark.parametrize('same_on_batch', [True, False])
test_valid_param_combinations(self, batch_size, sharpness, same_on_batch, device, dtype)
sharpness.to(device=device, dtype=dtype)
torch.tensor([-1, 5])
torch.tensor([3])
test_invalid_param_combinations(self, sharpness, device, dtype)
pytest.raises(Exception)
sharpness.to(device=device, dtype=dtype)
test_random_gen(self, device, dtype)
torch.manual_seed(42)
torch.tensor([0., 1.], device=device, dtype=dtype)
tensor([0.8823, 0.9150, 0.3829, 0.9593, 0.3904, 0.6009, 0.2566, 0.7936], device=device, dtype=dtype)
res.keys()
expected.keys()
assert_allclose(res['sharpness_factor'], expected['sharpness_factor'], rtol=1e-4, atol=1e-4)
test_same_on_batch(self, device, dtype)
torch.manual_seed(42)
torch.tensor([0., 1.], device=device, dtype=dtype)
tensor([0.8823, 0.8823, 0.8823, 0.8823, 0.8823, 0.8823, 0.8823, 0.8823], device=device, dtype=dtype)
res.keys()
expected.keys()
assert_allclose(res['sharpness_factor'], expected['sharpness_factor'], rtol=1e-4, atol=1e-4)
TestRandomMixUpGen(RandomGeneratorBaseTests)
pytest.mark.parametrize('batch_size', [0, 1, 8])
pytest.mark.parametrize('p', [0., 0.5, 1.])
pytest.mark.parametrize('lambda_val', [None, torch.tensor([0., 1.])
pytest.mark.parametrize('same_on_batch', [True, False])
test_valid_param_combinations(self, batch_size, p, lambda_val, same_on_batch, device, dtype)
lambda_val.to(device=device, dtype=dtype)
torch.tensor([-1, 1])
torch.tensor([0, 2])
torch.tensor([0, 0.5, 1])
test_invalid_param_combinations(self, lambda_val, device, dtype)
pytest.raises(Exception)
random_mixup_generator(batch_size=8, lambda_val=lambda_val.to(device=device, dtype=dtype)
test_random_gen(self, device, dtype)
torch.manual_seed(42)
torch.tensor([0., 1.], device=device, dtype=dtype)
torch.tensor([6, 1, 0, 7, 2, 5, 3, 4], device=device, dtype=torch.long)
res.keys()
expected.keys()
assert_allclose(res['mixup_pairs'], expected['mixup_pairs'], rtol=1e-4, atol=1e-4)
assert_allclose(res['mixup_lambdas'], expected['mixup_lambdas'], rtol=1e-4, atol=1e-4)
test_same_on_batch(self, device, dtype)
torch.manual_seed(9)
torch.tensor([0., 1.], device=device, dtype=dtype)
torch.tensor([4, 6, 7, 5, 0, 1, 3, 2], device=device, dtype=torch.long)
res.keys()
expected.keys()
assert_allclose(res['mixup_pairs'], expected['mixup_pairs'], rtol=1e-4, atol=1e-4)
assert_allclose(res['mixup_lambdas'], expected['mixup_lambdas'], rtol=1e-4, atol=1e-4)
TestRandomCutMixGen(RandomGeneratorBaseTests)
pytest.mark.parametrize('batch_size', [0, 1, 8])
pytest.mark.parametrize('p', [0, 0.5, 1.])
pytest.mark.parametrize('width,height', [(200, 200)
pytest.mark.parametrize('num_mix', [1, 3])
pytest.mark.parametrize('beta', [None, torch.tensor(1e-15)
torch.tensor(1.)
pytest.mark.parametrize('cut_size', [None, torch.tensor([0., 1.])
torch.tensor([0.3, 0.6])
pytest.mark.parametrize('same_on_batch', [True, False])
beta.to(device=device, dtype=dtype)
isinstance(beta, (torch.Tensor)
cut_size.to(device=device, dtype=dtype)
isinstance(cut_size, (torch.Tensor)
torch.tensor([0., 1.])
torch.tensor([-1., 1.])
torch.tensor([0., 2.])
pytest.mark.parametrize('same_on_batch', [True, False])
test_invalid_param_combinations(self, width, height, num_mix, beta, cut_size, same_on_batch, device, dtype)
pytest.raises(Exception)
beta.to(device=device, dtype=dtype)
isinstance(beta, (torch.Tensor)
beta.to(device=device, dtype=dtype)
isinstance(cut_size, (torch.Tensor)
test_random_gen(self, device, dtype)
torch.manual_seed(42)
torch.tensor(1., device=device, dtype=dtype)
torch.tensor([0., 1.], device=device, dtype=dtype)