Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
[[2., 2.],
[2., 2.]],
[[1., 1.],
[1., 1.]]],
[[[3., 3.],
[3., 3.]],
[[2., 2.],
[2., 2.]],
[[1., 1.],
[1., 1.]]]]) # 2x3x2x2
f = color.RgbToBgr()
out = f(data)
assert_allclose(out, expected)
[[2., 2.],
[2., 2.]],
[[3., 3.],
[3., 3.]]]) # 3x2x2
expected = torch.tensor([[[3., 3.],
[3., 3.]],
[[2., 2.],
[2., 2.]],
[[1., 1.],
[1., 1.]]]) # 3x2x2
f = color.RgbToBgr()
assert_allclose(f(data), expected)
def test_gradcheck(self):
# prepare input data
data = torch.tensor([[[1., 1.],
[1., 1.]],
[[2., 2.],
[2., 2.]],
[[3., 3.],
[3., 3.]]]) # 3x2x2
data = utils.tensor_to_gradcheck_var(data) # to var
assert gradcheck(color.RgbToBgr(), (data,),
raise_exception=True)