π Geometric Computer Vision Library for Spatial AI
Python artificial-intelligencecomputer-visiondeep-learninghacktoberfestimage-processingmachine-learningneural-networkpythonpytorchroboticsspatial-ai
remove math lib and update test
pulkit-khandelwal900eb6abd88f
diff --git a/test/test_image.py b/test/test_image.pyindex ea0b4d856..205609ec4 100644--- a/test/test_image.py+++ b/test/test_image.py@@ -82,3 +82,14 @@ class TestLaplacian:input = torch.rand(batch_shape).to(torch.device(device_type))laplace = image.Laplacian(kernel_size)assert laplace(input).shape == batch_shape++ def test_gradcheck(self):+ # test parameters+ batch_shape = (2, 3, 11, 7)+ kernel_size = (3, 9)++ # evaluate function gradient+ input = torch.rand(batch_shape)+ input = utils.tensor_to_gradcheck_var(input)+ assert gradcheck(image.laplacian, (input, kernel_size,),+ raise_exception=True)diff --git a/torchgeometry/image/laplacian.py b/torchgeometry/image/laplacian.pyindex 27d701826..7692ee5f9 100644--- a/torchgeometry/image/laplacian.py+++ b/torchgeometry/image/laplacian.py@@ -1,6 +1,5 @@from typing import Tuple-import mathimport torchimport torch.nn as nnfrom torch.nn.functional import conv2d@@ -79,7 +78,7 @@ def get_laplacian_kernel2d(kernel_size: int) -> torch.Tensor:kernel = torch.ones((kernel_size, kernel_size))mid = kernel_size // 2- kernel[mid, mid] = 1 - math.pow(kernel_size, 2)+ kernel[mid, mid] = 1 - kernel_size ** 2kernel_2d: torch.Tensor = kernelreturn kernel_2d