コード例 #1
0
    def test_cost_function3(self, omicron, omega):
        X = array([[0.10, 0.30, -0.50], [-0.20, 0, -0.60], [0, 0.20, 0.45]])
        y = array([[0], [2], [1]])
        n_hidden_layers = 1
        num_labels = 3
        _lambda = 10

        theta = empty((n_hidden_layers + 1), dtype=object)
        theta[0] = omicron
        theta[1] = omega

        assert_allclose(cost_function(X, y, theta, _lambda, num_labels,
                                      n_hidden_layers),
                        21.443,
                        rtol=0,
                        atol=0.001,
                        equal_nan=False)
コード例 #2
0
    def test_cost_function4(self, omicron, omega, kappa, upsilon):
        X = array([[0.10, 0.30, -0.50], [-0.20, 0, -0.60], [0, 0.20, 0.45]])
        y = array([[0], [2], [1]])
        n_hidden_layers = 3
        num_labels = 3
        _lambda = 0

        theta = empty((n_hidden_layers + 1), dtype=object)
        theta[0] = omicron
        theta[1] = kappa
        theta[2] = upsilon
        theta[3] = omega

        assert_allclose(cost_function(X, y, theta, _lambda, num_labels,
                                      n_hidden_layers),
                        5.6617,
                        rtol=0,
                        atol=0.001,
                        equal_nan=False)