Esempio n. 1
0
    def test_create_gaussian_initializer_4d(self):
        """Ensures correct output from create_gaussian_initializer.

        In this case, the desired matrix is 4-D.
        """

        this_init_function = backwards_opt.create_gaussian_initializer(
            mean=GAUSSIAN_MEAN, standard_deviation=GAUSSIAN_STANDARD_DEVIATION)

        this_matrix = this_init_function(ARRAY_DIMENSIONS_4D)
        self.assertTrue(
            numpy.allclose(this_matrix, GAUSSIAN_MATRIX_4D, atol=TOLERANCE))
def _create_initializer(init_function_name):
    """Creates initializer function.

    :param init_function_name: See documentation at top of file.
    :return: init_function: Initializer function.
    """

    if init_function_name == backwards_opt.CONSTANT_INIT_FUNCTION_NAME:
        return backwards_opt.create_constant_initializer(0.)

    if init_function_name == backwards_opt.UNIFORM_INIT_FUNCTION_NAME:
        return backwards_opt.create_uniform_random_initializer(min_value=-1.,
                                                               max_value=1.)

    return backwards_opt.create_gaussian_initializer(mean=0.,
                                                     standard_deviation=1.)