Esempio n. 1
0
    def check_double_backward(self, m_data, v_data, y_grad, m_grad_grad,
                              v_grad_grad):
        gaussian = functions.Gaussian()

        def f(m, v):
            return gaussian.apply((m, v))

        gradient_check.check_double_backward(
            f, (m_data, v_data), y_grad, (m_grad_grad, v_grad_grad),
            atol=5e-4, rtol=5e-3)
    def check_backward(self, m_data, v_data, y_grad):
        # Instantiate the FunctionNode object outside the function that is
        # tested in order to reuse the same noise for the numerical gradient
        # computations (the noise is generated once during its first forward
        # pass, then reused)
        # TODO(hvy): Do no expose interals of the tested function using
        # e.g. numpy.random.RandomState
        gaussian = functions.Gaussian()

        def f(m, v):
            return gaussian.apply((m, v))[0]

        gradient_check.check_backward(f, (m_data, v_data), y_grad,
                                      **self.check_backward_options)
Esempio n. 3
0
 def check_backward(self, m_data, v_data, y_grad):
     gradient_check.check_backward(functions.Gaussian(), (m_data, v_data),
                                   y_grad, **self.check_backward_options)
Esempio n. 4
0
 def check_backward(self, m_data, v_data, y_grad):
     gradient_check.check_backward(
         functions.Gaussian(), (m_data, v_data), y_grad,
         atol=1e-4, rtol=1e-3)