本文整理汇总了Python中losses.maximum_mean_discrepancy方法的典型用法代码示例。如果您正苦于以下问题:Python losses.maximum_mean_discrepancy方法的具体用法?Python losses.maximum_mean_discrepancy怎么用?Python losses.maximum_mean_discrepancy使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类losses
的用法示例。
在下文中一共展示了losses.maximum_mean_discrepancy方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_mmd_name
# 需要导入模块: import losses [as 别名]
# 或者: from losses import maximum_mean_discrepancy [as 别名]
def test_mmd_name(self):
with self.test_session():
x = tf.random_uniform((2, 3), seed=1)
kernel = partial(utils.gaussian_kernel_matrix, sigmas=tf.constant([1.]))
loss = losses.maximum_mean_discrepancy(x, x, kernel)
self.assertEquals(loss.op.name, 'MaximumMeanDiscrepancy/value')
示例2: test_mmd_is_zero_when_inputs_are_same
# 需要导入模块: import losses [as 别名]
# 或者: from losses import maximum_mean_discrepancy [as 别名]
def test_mmd_is_zero_when_inputs_are_same(self):
with self.test_session():
x = tf.random_uniform((2, 3), seed=1)
kernel = partial(utils.gaussian_kernel_matrix, sigmas=tf.constant([1.]))
self.assertEquals(0, losses.maximum_mean_discrepancy(x, x, kernel).eval())
示例3: test_fast_mmd_is_similar_to_slow_mmd
# 需要导入模块: import losses [as 别名]
# 或者: from losses import maximum_mean_discrepancy [as 别名]
def test_fast_mmd_is_similar_to_slow_mmd(self):
with self.test_session():
x = tf.constant(np.random.normal(size=(2, 3)), tf.float32)
y = tf.constant(np.random.rand(2, 3), tf.float32)
cost_old = MaximumMeanDiscrepancySlow(x, y, [1.]).eval()
kernel = partial(utils.gaussian_kernel_matrix, sigmas=tf.constant([1.]))
cost_new = losses.maximum_mean_discrepancy(x, y, kernel).eval()
self.assertAlmostEqual(cost_old, cost_new, delta=1e-5)
示例4: test_multiple_sigmas
# 需要导入模块: import losses [as 别名]
# 或者: from losses import maximum_mean_discrepancy [as 别名]
def test_multiple_sigmas(self):
with self.test_session():
x = tf.constant(np.random.normal(size=(2, 3)), tf.float32)
y = tf.constant(np.random.rand(2, 3), tf.float32)
sigmas = tf.constant([2., 5., 10, 20, 30])
kernel = partial(utils.gaussian_kernel_matrix, sigmas=sigmas)
cost_old = MaximumMeanDiscrepancySlow(x, y, [2., 5., 10, 20, 30]).eval()
cost_new = losses.maximum_mean_discrepancy(x, y, kernel=kernel).eval()
self.assertAlmostEqual(cost_old, cost_new, delta=1e-5)
示例5: test_mmd_is_zero_when_distributions_are_same
# 需要导入模块: import losses [as 别名]
# 或者: from losses import maximum_mean_discrepancy [as 别名]
def test_mmd_is_zero_when_distributions_are_same(self):
with self.test_session():
x = tf.random_uniform((1000, 10), seed=1)
y = tf.random_uniform((1000, 10), seed=3)
kernel = partial(utils.gaussian_kernel_matrix, sigmas=tf.constant([100.]))
loss = losses.maximum_mean_discrepancy(x, y, kernel=kernel).eval()
self.assertAlmostEqual(0, loss, delta=1e-4)