Beispiel #1
0
                            atol=0.0,
                            rtol=1e-6)


@test_util.test_all_tf_execution_regimes
class WeibullTestStaticShapeFloat32(test_util.TestCase, _WeibullTest):
    dtype = np.float32
    use_static_shape = True


@test_util.test_all_tf_execution_regimes
class WeibullTestStaticShapeFloat64(test_util.TestCase, _WeibullTest):
    dtype = np.float64
    use_static_shape = True


@test_util.test_all_tf_execution_regimes
class WeibullTestDynamicShapeFloat32(test_util.TestCase, _WeibullTest):
    dtype = np.float32
    use_static_shape = False


@test_util.test_all_tf_execution_regimes
class WeibullTestDynamicShapeFloat64(test_util.TestCase, _WeibullTest):
    dtype = np.float64
    use_static_shape = True


if __name__ == '__main__':
    test_util.main()
Beispiel #2
0
            js_bound_3, self.evaluate(tf.tile(js_bound_1[tf.newaxis, ], [3])))

    def test_lower_bound_nguyen_wainwright_jordan(self):
        # Numerical test against theoretical values
        nwj_bound = self.evaluate(
            mi.lower_bound_nguyen_wainwright_jordan(self.optimal_critic))
        self.assertAllInRange(
            nwj_bound,
            lower_bound=self.theoretical_mi - LOWER_BOUND_MIN_GAP,
            upper_bound=self.theoretical_mi + LOWER_BOUND_MAX_GAP)

        # Check the masked against none masked version
        nwj_bound_1 = mi.lower_bound_nguyen_wainwright_jordan(self.scores)
        positive_mask = np.eye(self.scores.shape[0], self.scores.shape[1])
        nwj_bound_2 = self.evaluate(
            mi.lower_bound_nguyen_wainwright_jordan(self.scores,
                                                    positive_mask,
                                                    validate_args=True))
        self.assertAllClose(nwj_bound_1, nwj_bound_2)

        # Check batched against none batched version
        nwj_bound_3 = self.evaluate(
            mi.lower_bound_nguyen_wainwright_jordan(
                tf.tile(self.scores[tf.newaxis, :, :], [3, 1, 1])))
        self.assertAllClose(nwj_bound_3,
                            self.evaluate(tf.tile(nwj_bound_1[None, ], [3])))


if __name__ == '__main__':
    tfp_test_util.main()