code stringlengths 3 6.57k |
|---|
pytest.mark.parametrize('batch_size', [0, 1, 8]) |
pytest.mark.parametrize('same_on_batch', [True, False]) |
test_valid_param_combinations(self, height, width, distortion_scale, batch_size, same_on_batch, device, dtype) |
distortion_scale.to(device=device, dtype=dtype) |
torch.tensor(0.5) |
torch.tensor(0.5) |
torch.tensor(-0.5) |
torch.tensor(1.5) |
torch.tensor([0., 0.5]) |
test_invalid_param_combinations(self, height, width, distortion_scale, device, dtype) |
pytest.raises(Exception) |
distortion_scale.to(device=device, dtype=dtype) |
test_random_gen(self, device, dtype) |
torch.manual_seed(42) |
random_perspective_generator(batch_size, 200, 200, torch.tensor(0.5, device=device, dtype=dtype) |
res.keys() |
expected.keys() |
assert_allclose(res['start_points'], expected['start_points']) |
assert_allclose(res['end_points'], expected['end_points']) |
test_same_on_batch(self, device, dtype) |
torch.manual_seed(42) |
torch.tensor(0.5, device=device, dtype=dtype) |
repeat(2, 1, 1) |
repeat(2, 1, 1) |
res.keys() |
expected.keys() |
assert_allclose(res['start_points'], expected['start_points']) |
assert_allclose(res['end_points'], expected['end_points']) |
TestRandomAffineGen(RandomGeneratorBaseTests) |
pytest.mark.parametrize('batch_size', [0, 1, 4]) |
pytest.mark.parametrize('height', [200]) |
pytest.mark.parametrize('width', [300]) |
pytest.mark.parametrize('degrees', [torch.tensor([0, 30]) |
pytest.mark.parametrize('translate', [None, torch.tensor([0.1, 0.1]) |
pytest.mark.parametrize('scale', [None, torch.tensor([0.7, 1.2]) |
pytest.mark.parametrize('shear', [None, torch.tensor([[0, 20], [0, 20]]) |
pytest.mark.parametrize('same_on_batch', [True, False]) |
degrees.to(device=device, dtype=dtype) |
translate.to(device=device, dtype=dtype) |
scale.to(device=device, dtype=dtype) |
shear.to(device=device, dtype=dtype) |
torch.tensor([10, 20]) |
torch.tensor([10, 20]) |
torch.tensor([10, 20, 30]) |
torch.tensor([10, 20]) |
torch.tensor([0.1]) |
torch.tensor([1, 2]) |
torch.tensor([0.1, 0.2, 0.3]) |
torch.tensor([10, 20]) |
torch.tensor([1]) |
torch.tensor([10, 20]) |
torch.tensor([1, 2, 3]) |
torch.tensor([10, 20]) |
torch.tensor([1]) |
torch.tensor([10, 20]) |
torch.tensor([1, 2]) |
torch.tensor([1, 2]) |
torch.tensor([1, 2, 3]) |
torch.tensor([1, 2]) |
torch.tensor([1, 2, 3, 4]) |
torch.tensor([1, 2]) |
torch.tensor([1, 2, 3, 4, 5]) |
test_invalid_param_combinations(self, height, width, degrees, translate, scale, shear, device, dtype) |
pytest.raises(Exception) |
degrees.to(device=device, dtype=dtype) |
translate.to(device=device, dtype=dtype) |
scale.to(device=device, dtype=dtype) |
shear.to(device=device, dtype=dtype) |
test_random_gen(self, device, dtype) |
torch.manual_seed(42) |
torch.tensor([10, 20], device=device, dtype=dtype) |
torch.tensor([0.1, 0.1], device=device, dtype=dtype) |
torch.tensor([0.7, 1.2], device=device, dtype=dtype) |
torch.tensor([[10, 20], [10, 20]], device=device, dtype=dtype) |
torch.tensor([[-4.3821, -9.7371], [4.0358, 11.7457]], device=device, dtype=dtype) |
torch.tensor([[99.5000, 99.5000], [99.5000, 99.5000]], device=device, dtype=dtype) |
torch.tensor([[0.8914, 0.8914], [1.1797, 1.1797]], device=device, dtype=dtype) |
torch.tensor([18.8227, 19.1500], device=device, dtype=dtype) |
torch.tensor([19.4077, 11.3319], device=device, dtype=dtype) |
torch.tensor([19.3460, 15.9358], device=device, dtype=dtype) |
res.keys() |
expected.keys() |
assert_allclose(res['translations'], expected['translations'], rtol=1e-4, atol=1e-4) |
assert_allclose(res['center'], expected['center'], rtol=1e-4, atol=1e-4) |
assert_allclose(res['scale'], expected['scale'], rtol=1e-4, atol=1e-4) |
assert_allclose(res['angle'], expected['angle'], rtol=1e-4, atol=1e-4) |
assert_allclose(res['sx'], expected['sx'], rtol=1e-4, atol=1e-4) |
assert_allclose(res['sy'], expected['sy'], rtol=1e-4, atol=1e-4) |
test_same_on_batch(self, device, dtype) |
torch.manual_seed(42) |
torch.tensor([10, 20], device=device, dtype=dtype) |
torch.tensor([0.1, 0.1], device=device, dtype=dtype) |
torch.tensor([0.7, 1.2], device=device, dtype=dtype) |
torch.tensor([[10, 20], [10, 20]], device=device, dtype=dtype) |
torch.tensor([[-4.6854, 18.3722], [-4.6854, 18.3722]], device=device, dtype=dtype) |
torch.tensor([[99.5000, 99.5000], [99.5000, 99.5000]], device=device, dtype=dtype) |
torch.tensor([[1.1575, 1.1575], [1.1575, 1.1575]], device=device, dtype=dtype) |
torch.tensor([18.8227, 18.8227], device=device, dtype=dtype) |
torch.tensor([13.9045, 13.9045], device=device, dtype=dtype) |
torch.tensor([16.0090, 16.0090], device=device, dtype=dtype) |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.