# Path: tensorflow_model_remediation/min_diff/losses/kernels/gaussian_kernel.py
# class GaussianKernel(base_kernel.MinDiffKernel):
#   def __init__(self, kernel_length: complex = 0.1, **kwargs):
#   def call(self, x: types.TensorType, y: types.TensorType) -> types.TensorType:
#   def get_config(self):


import tensorflow as tf
from tensorflow_model_remediation.min_diff.losses.kernels import gaussian_kernel
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

"""Test gaussian_kernel module."""




class GaussianKernelTest(tf.test.TestCase):

  def testGaussianKernel(self):
    # Under certain conditions, the kernel output resembles the identity
    # (within the tolerance of the checks).
    # Specifically, this is true when the minimum distance, d, between any two
    # elements in the input is greater than D = -ln(tol) * kernel_length**2
    # where:
    #   - tol: assertion tolerance (these tests ues 1e-6)
    #   - d: minimum{norm(x_i - y_i)
    #                for x_i = x[i, :], y_j = y[j, :] for all i neq j}
    #   - kernel_length: argument to kernel initialization
    #
    # In the test below, we use max(kernel_length) == 0.1 which gives us
    # max(D)~=0.138. Given this bound, we sometines use d=0.2 (meaning that each
    # element is at least 0.2 greater or smaller than every other element in the
    # input). When we do this, we expect the output to be close to the identity.
    for kernel_length in [0.05, 0.075, 0.1]:

# Path: tensorflow_model_remediation/min_diff/losses/kernels/gaussian_kernel.py
# class GaussianKernel(base_kernel.MinDiffKernel):
#   def __init__(self, kernel_length: complex = 0.1, **kwargs):
#   def call(self, x: types.TensorType, y: types.TensorType) -> types.TensorType:
#   def get_config(self):


# Path: tensorflow_model_remediation/min_diff/losses/kernels/gaussian_kernel_test.py
import tensorflow as tf
from tensorflow_model_remediation.min_diff.losses.kernels import gaussian_kernel

#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

"""Test gaussian_kernel module."""




class GaussianKernelTest(tf.test.TestCase):

  def testGaussianKernel(self):
    # Under certain conditions, the kernel output resembles the identity
    # (within the tolerance of the checks).
    # Specifically, this is true when the minimum distance, d, between any two
    # elements in the input is greater than D = -ln(tol) * kernel_length**2
    # where:
    #   - tol: assertion tolerance (these tests ues 1e-6)
    #   - d: minimum{norm(x_i - y_i)
    #                for x_i = x[i, :], y_j = y[j, :] for all i neq j}
    #   - kernel_length: argument to kernel initialization
    #
    # In the test below, we use max(kernel_length) == 0.1 which gives us
    # max(D)~=0.138. Given this bound, we sometines use d=0.2 (meaning that each
    # element is at least 0.2 greater or smaller than every other element in the
    # input). When we do this, we expect the output to be close to the identity.
    for kernel_length in [0.05, 0.075, 0.1]:

      gaussian_kernel_fn = gaussian_kernel.GaussianKernel(kernel_length)