python类get_printoptions()的实例源码

min_max_norm.py 文件源码 项目:merlin 作者: CSTR-Edinburgh 项目源码 文件源码 阅读 31 收藏 0 点赞 0 评论 0
def compute_mean(self, file_list):

        logger = logging.getLogger("acoustic_norm")

        mean_vector = numpy.zeros((1, self.feature_dimension))
        all_frame_number = 0

        io_funcs = BinaryIOCollection()
        for file_name in file_list:
            features = io_funcs.load_binary_file(file_name, self.feature_dimension)
            current_frame_number = features.size // self.feature_dimension
            mean_vector += numpy.reshape(numpy.sum(features, axis=0), (1, self.feature_dimension))
            all_frame_number += current_frame_number

        mean_vector /= float(all_frame_number)

        # po=numpy.get_printoptions()
        # numpy.set_printoptions(precision=2, threshold=20, linewidth=1000, edgeitems=4)
        logger.info('computed mean vector of length %d :' % mean_vector.shape[1] )
        logger.info(' mean: %s' % mean_vector)
        # restore the print options
        # numpy.set_printoptions(po)

        return  mean_vector
feature_normalisation_base.py 文件源码 项目:merlin 作者: CSTR-Edinburgh 项目源码 文件源码 阅读 36 收藏 0 点赞 0 评论 0
def compute_mean(self, file_list, start_index, end_index):

        local_feature_dimension = end_index - start_index

        mean_vector = numpy.zeros((1, local_feature_dimension))
        all_frame_number = 0

        io_funcs = BinaryIOCollection()
        for file_name in file_list:
            features, current_frame_number = io_funcs.load_binary_file_frame(file_name, self.feature_dimension)

            mean_vector += numpy.reshape(numpy.sum(features[:, start_index:end_index], axis=0), (1, local_feature_dimension))
            all_frame_number += current_frame_number

        mean_vector /= float(all_frame_number)

        # po=numpy.get_printoptions()
        # numpy.set_printoptions(precision=2, threshold=20, linewidth=1000, edgeitems=4)
        self.logger.info('computed mean vector of length %d :' % mean_vector.shape[1] )
        self.logger.info(' mean: %s' % mean_vector)
        # restore the print options
        # numpy.set_printoptions(po)

        return  mean_vector
min_max_norm.py 文件源码 项目:world_merlin 作者: pbaljeka 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
def compute_mean(self, file_list):

        logger = logging.getLogger("acoustic_norm")

        mean_vector = numpy.zeros((1, self.feature_dimension))
        all_frame_number = 0

        io_funcs = BinaryIOCollection()
        for file_name in file_list:
            features = io_funcs.load_binary_file(file_name, self.feature_dimension)
            current_frame_number = features.size / self.feature_dimension
            mean_vector += numpy.reshape(numpy.sum(features, axis=0), (1, self.feature_dimension))
            all_frame_number += current_frame_number

        mean_vector /= float(all_frame_number)

        # po=numpy.get_printoptions()
        # numpy.set_printoptions(precision=2, threshold=20, linewidth=1000, edgeitems=4)
        logger.info('computed mean vector of length %d :' % mean_vector.shape[1] )
        logger.info(' mean: %s' % mean_vector)
        # restore the print options
        # numpy.set_printoptions(po)

        return  mean_vector
feature_normalisation_base.py 文件源码 项目:world_merlin 作者: pbaljeka 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def compute_mean(self, file_list, start_index, end_index):

        local_feature_dimension = end_index - start_index

        mean_vector = numpy.zeros((1, local_feature_dimension))
        all_frame_number = 0

        io_funcs = BinaryIOCollection()
        for file_name in file_list:
            features, current_frame_number = io_funcs.load_binary_file_frame(file_name, self.feature_dimension)

            mean_vector += numpy.reshape(numpy.sum(features[:, start_index:end_index], axis=0), (1, local_feature_dimension))
            all_frame_number += current_frame_number

        mean_vector /= float(all_frame_number)

        # po=numpy.get_printoptions()
        # numpy.set_printoptions(precision=2, threshold=20, linewidth=1000, edgeitems=4)
        self.logger.info('computed mean vector of length %d :' % mean_vector.shape[1] )
        self.logger.info(' mean: %s' % mean_vector)
        # restore the print options
        # numpy.set_printoptions(po)

        return  mean_vector
logger.py 文件源码 项目:mlens 作者: flennerhag 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def pformat(obj, indent=0, depth=3):
    if 'numpy' in sys.modules:
        import numpy as np
        print_options = np.get_printoptions()
        np.set_printoptions(precision=6, threshold=64, edgeitems=1)
    else:
        print_options = None
    out = pprint.pformat(obj, depth=depth, indent=indent)
    if print_options:
        np.set_printoptions(**print_options)
    return out


###############################################################################
# class `Logger`
###############################################################################
min_max_norm.py 文件源码 项目:mimicry.ai 作者: fizerkhan 项目源码 文件源码 阅读 28 收藏 0 点赞 0 评论 0
def compute_mean(self, file_list):

        logger = logging.getLogger("acoustic_norm")

        mean_vector = numpy.zeros((1, self.feature_dimension))
        all_frame_number = 0

        io_funcs = BinaryIOCollection()
        for file_name in file_list:
            features = io_funcs.load_binary_file(file_name, self.feature_dimension)
            current_frame_number = features.size / self.feature_dimension
            mean_vector += numpy.reshape(numpy.sum(features, axis=0), (1, self.feature_dimension))
            all_frame_number += current_frame_number

        mean_vector /= float(all_frame_number)

        # po=numpy.get_printoptions()
        # numpy.set_printoptions(precision=2, threshold=20, linewidth=1000, edgeitems=4)
        logger.info('computed mean vector of length %d :' % mean_vector.shape[1] )
        logger.info(' mean: %s' % mean_vector)
        # restore the print options
        # numpy.set_printoptions(po)

        return  mean_vector
feature_normalisation_base.py 文件源码 项目:mimicry.ai 作者: fizerkhan 项目源码 文件源码 阅读 29 收藏 0 点赞 0 评论 0
def compute_mean(self, file_list, start_index, end_index):

        local_feature_dimension = end_index - start_index

        mean_vector = numpy.zeros((1, local_feature_dimension))
        all_frame_number = 0

        io_funcs = BinaryIOCollection()
        for file_name in file_list:
            features, current_frame_number = io_funcs.load_binary_file_frame(file_name, self.feature_dimension)

            mean_vector += numpy.reshape(numpy.sum(features[:, start_index:end_index], axis=0), (1, local_feature_dimension))
            all_frame_number += current_frame_number

        mean_vector /= float(all_frame_number)

        # po=numpy.get_printoptions()
        # numpy.set_printoptions(precision=2, threshold=20, linewidth=1000, edgeitems=4)
        self.logger.info('computed mean vector of length %d :' % mean_vector.shape[1] )
        self.logger.info(' mean: %s' % mean_vector)
        # restore the print options
        # numpy.set_printoptions(po)

        return  mean_vector
logger.py 文件源码 项目:rankpy 作者: dmitru 项目源码 文件源码 阅读 26 收藏 0 点赞 0 评论 0
def pformat(obj, indent=0, depth=3):
    if 'numpy' in sys.modules:
        import numpy as np
        print_options = np.get_printoptions()
        np.set_printoptions(precision=6, threshold=64, edgeitems=1)
    else:
        print_options = None
    out = pprint.pformat(obj, depth=depth, indent=indent)
    if print_options:
        np.set_printoptions(**print_options)
    return out


###############################################################################
# class `Logger`
###############################################################################
episode_hooks.py 文件源码 项目:polyaxon 作者: polyaxon 项目源码 文件源码 阅读 26 收藏 0 点赞 0 评论 0
def after_run(self, run_context, run_values):
        global_episode = run_values.results['global_episode']
        if can_run_hook(run_context):
            if self._timer.should_trigger_for_episode(global_episode):
                original = np.get_printoptions()
                np.set_printoptions(suppress=True)
                elapsed_secs, _ = self._timer.update_last_triggered_episode(global_episode)
                if self._formatter:
                    logging.info(self._formatter(run_values.results))
                else:
                    stats = []
                    for tag in self._tag_order:
                        stats.append("%s = %s" % (tag, run_values.results[tag]))
                    if elapsed_secs is not None:
                        logging.info("%s (%.3f sec)", ", ".join(stats), elapsed_secs)
                    else:
                        logging.info("%s", ", ".join(stats))
                np.set_printoptions(**original)
logger.py 文件源码 项目:Parallel-SGD 作者: angadgill 项目源码 文件源码 阅读 28 收藏 0 点赞 0 评论 0
def pformat(obj, indent=0, depth=3):
    if 'numpy' in sys.modules:
        import numpy as np
        print_options = np.get_printoptions()
        np.set_printoptions(precision=6, threshold=64, edgeitems=1)
    else:
        print_options = None
    out = pprint.pformat(obj, depth=depth, indent=indent)
    if print_options:
        np.set_printoptions(**print_options)
    return out


###############################################################################
# class `Logger`
###############################################################################
util.py 文件源码 项目:treecat 作者: posterior 项目源码 文件源码 阅读 26 收藏 0 点赞 0 评论 0
def np_printoptions(**kwargs):
    """Context manager to temporarily set numpy print options."""
    old = np.get_printoptions()
    np.set_printoptions(**kwargs)
    yield
    np.set_printoptions(**old)
test_arrayprint.py 文件源码 项目:radar 作者: amoose136 项目源码 文件源码 阅读 27 收藏 0 点赞 0 评论 0
def setUp(self):
        self.oldopts = np.get_printoptions()
mutual_info_estimation.py 文件源码 项目:IDNNs 作者: ravidziv 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
def printoptions(*args, **kwargs):
    original = np.get_printoptions()
    np.set_printoptions(*args, **kwargs)
    try:
        yield
    finally:
        np.set_printoptions(**original)
mean_variance_norm.py 文件源码 项目:merlin 作者: CSTR-Edinburgh 项目源码 文件源码 阅读 29 收藏 0 点赞 0 评论 0
def compute_mean(self, file_list, start_index, end_index):

        logger = logging.getLogger('feature_normalisation')

        local_feature_dimension = end_index - start_index

        mean_vector = numpy.zeros((1, local_feature_dimension))
        all_frame_number = 0

        io_funcs = HTKFeat_read()
        for file_name in file_list:
            features, current_frame_number = io_funcs.getall(file_name)
#            io_funcs = HTK_Parm_IO()
#            io_funcs.read_htk(file_name)
#            features = io_funcs.data
#            current_frame_number = io_funcs.n_samples

            mean_vector += numpy.reshape(numpy.sum(features[:, start_index:end_index], axis=0), (1, local_feature_dimension))
            all_frame_number += current_frame_number

        mean_vector /= float(all_frame_number)

        # setting the print options in this way seems to break subsequent printing of numpy float32 types
        # no idea what is going on - removed until this can be solved
        # po=numpy.get_printoptions()
        # numpy.set_printoptions(precision=2, threshold=20, linewidth=1000, edgeitems=4)
        logger.info('computed mean vector of length %d :' % mean_vector.shape[1] )
        logger.info(' mean: %s' % mean_vector)
        # restore the print options
        # numpy.set_printoptions(po)

        self.mean_vector = mean_vector

        return  mean_vector
mean_variance_norm.py 文件源码 项目:merlin 作者: CSTR-Edinburgh 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def compute_std(self, file_list, mean_vector, start_index, end_index):

        logger = logging.getLogger('feature_normalisation')

        local_feature_dimension = end_index - start_index

        std_vector = numpy.zeros((1, self.feature_dimension))
        all_frame_number = 0

        io_funcs = HTKFeat_read()
        for file_name in file_list:
            features, current_frame_number = io_funcs.getall(file_name)

            mean_matrix = numpy.tile(mean_vector, (current_frame_number, 1))

            std_vector += numpy.reshape(numpy.sum((features[:, start_index:end_index] - mean_matrix) ** 2, axis=0), (1, local_feature_dimension))
            all_frame_number += current_frame_number

        std_vector /= float(all_frame_number)

        std_vector = std_vector ** 0.5

        # setting the print options in this way seems to break subsequent printing of numpy float32 types
        # no idea what is going on - removed until this can be solved
        # po=numpy.get_printoptions()
        # numpy.set_printoptions(precision=2, threshold=20, linewidth=1000, edgeitems=4)
        logger.info('computed  std vector of length %d' % std_vector.shape[1] )
        logger.info('  std: %s' % std_vector)
        # restore the print options
        # numpy.set_printoptions(po)

        self.std_vector = std_vector

        return  std_vector
label_composer.py 文件源码 项目:merlin 作者: CSTR-Edinburgh 项目源码 文件源码 阅读 28 收藏 0 点赞 0 评论 0
def printoptions(*args, **kwargs):
    original = numpy.get_printoptions()
    numpy.set_printoptions(*args, **kwargs)
    yield
    numpy.set_printoptions(**original)
min_max_norm.py 文件源码 项目:merlin 作者: CSTR-Edinburgh 项目源码 文件源码 阅读 27 收藏 0 点赞 0 评论 0
def find_min_max_values(self, in_file_list):

        logger = logging.getLogger("acoustic_norm")

        file_number = len(in_file_list)
        min_value_matrix = numpy.zeros((file_number, self.feature_dimension))
        max_value_matrix = numpy.zeros((file_number, self.feature_dimension))
        io_funcs = BinaryIOCollection()
        for i in range(file_number):
            features = io_funcs.load_binary_file(in_file_list[i], self.feature_dimension)

            temp_min = numpy.amin(features, axis = 0)
            temp_max = numpy.amax(features, axis = 0)

            min_value_matrix[i, ] = temp_min;
            max_value_matrix[i, ] = temp_max;

        self.min_vector = numpy.amin(min_value_matrix, axis = 0)
        self.max_vector = numpy.amax(max_value_matrix, axis = 0)
        self.min_vector = numpy.reshape(self.min_vector, (1, self.feature_dimension))
        self.max_vector = numpy.reshape(self.max_vector, (1, self.feature_dimension))

        # po=numpy.get_printoptions()
        # numpy.set_printoptions(precision=2, threshold=20, linewidth=1000, edgeitems=4)
        logger.info('across %d files found min/max values of length %d:' % (file_number,self.feature_dimension) )
        logger.info('  min: %s' % self.min_vector)
        logger.info('  max: %s' % self.max_vector)
        # restore the print options
        # numpy.set_printoptions(po)
feature_normalisation_base.py 文件源码 项目:merlin 作者: CSTR-Edinburgh 项目源码 文件源码 阅读 33 收藏 0 点赞 0 评论 0
def find_min_max_values(self, in_file_list, start_index, end_index):

        local_feature_dimension = end_index - start_index

        file_number = len(in_file_list)
        min_value_matrix = numpy.zeros((file_number, local_feature_dimension))
        max_value_matrix = numpy.zeros((file_number, local_feature_dimension))
        io_funcs = BinaryIOCollection()
        for i in range(file_number):
            features = io_funcs.load_binary_file(in_file_list[i], self.feature_dimension)

            temp_min = numpy.amin(features[:, start_index:end_index], axis = 0)
            temp_max = numpy.amax(features[:, start_index:end_index], axis = 0)

            min_value_matrix[i, ] = temp_min;
            max_value_matrix[i, ] = temp_max;

        self.min_vector = numpy.amin(min_value_matrix, axis = 0)
        self.max_vector = numpy.amax(max_value_matrix, axis = 0)
        self.min_vector = numpy.reshape(self.min_vector, (1, local_feature_dimension))
        self.max_vector = numpy.reshape(self.max_vector, (1, local_feature_dimension))

        # po=numpy.get_printoptions()
        # numpy.set_printoptions(precision=2, threshold=20, linewidth=1000, edgeitems=4)
        self.logger.info('found min/max values of length %d:' % local_feature_dimension)
        self.logger.info('  min: %s' % self.min_vector)
        self.logger.info('  max: %s' % self.max_vector)
        # restore the print options
        # numpy.set_printoptions(po)
feature_normalisation_base.py 文件源码 项目:merlin 作者: CSTR-Edinburgh 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
def compute_std(self, file_list, mean_vector, start_index, end_index):
        local_feature_dimension = end_index - start_index

        std_vector = numpy.zeros((1, self.feature_dimension))
        all_frame_number = 0

        io_funcs = BinaryIOCollection()
        for file_name in file_list:
            features, current_frame_number = io_funcs.load_binary_file_frame(file_name, self.feature_dimension)

            mean_matrix = numpy.tile(mean_vector, (current_frame_number, 1))

            std_vector += numpy.reshape(numpy.sum((features[:, start_index:end_index] - mean_matrix) ** 2, axis=0), (1, local_feature_dimension))
            all_frame_number += current_frame_number

        std_vector /= float(all_frame_number)

        std_vector = std_vector ** 0.5

        # po=numpy.get_printoptions()
        # numpy.set_printoptions(precision=2, threshold=20, linewidth=1000, edgeitems=4)
        self.logger.info('computed  std vector of length %d' % std_vector.shape[1] )
        self.logger.info('  std: %s' % std_vector)
        # restore the print options
        # numpy.set_printoptions(po)

        return  std_vector
mean_variance_norm.py 文件源码 项目:merlin 作者: CSTR-Edinburgh 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def compute_mean(self, file_list, start_index, end_index):

        logger = logging.getLogger('feature_normalisation')

        local_feature_dimension = end_index - start_index

        mean_vector = numpy.zeros((1, local_feature_dimension))
        all_frame_number = 0

        io_funcs = BinaryIOCollection()
        for file_name in file_list:
            features, current_frame_number = io_funcs.load_binary_file_frame(file_name, self.feature_dimension)

            mean_vector += numpy.reshape(numpy.sum(features[:, start_index:end_index], axis=0), (1, local_feature_dimension))
            all_frame_number += current_frame_number

        mean_vector /= float(all_frame_number)

        # setting the print options in this way seems to break subsequent printing of numpy float32 types
        # no idea what is going on - removed until this can be solved
        # po=numpy.get_printoptions()
        # numpy.set_printoptions(precision=2, threshold=20, linewidth=1000, edgeitems=4)
        logger.info('computed mean vector of length %d :' % mean_vector.shape[1] )
        logger.info(' mean: %s' % mean_vector)
        # restore the print options
        # numpy.set_printoptions(po)

        self.mean_vector = mean_vector

        return  mean_vector
mean_variance_norm.py 文件源码 项目:merlin 作者: CSTR-Edinburgh 项目源码 文件源码 阅读 36 收藏 0 点赞 0 评论 0
def compute_std(self, file_list, mean_vector, start_index, end_index):

        logger = logging.getLogger('feature_normalisation')

        local_feature_dimension = end_index - start_index

        std_vector = numpy.zeros((1, self.feature_dimension))
        all_frame_number = 0

        io_funcs = BinaryIOCollection()
        for file_name in file_list:
            features, current_frame_number = io_funcs.load_binary_file_frame(file_name, self.feature_dimension)

            mean_matrix = numpy.tile(mean_vector, (current_frame_number, 1))

            std_vector += numpy.reshape(numpy.sum((features[:, start_index:end_index] - mean_matrix) ** 2, axis=0), (1, local_feature_dimension))
            all_frame_number += current_frame_number

        std_vector /= float(all_frame_number)

        std_vector = std_vector ** 0.5

        # setting the print options in this way seems to break subsequent printing of numpy float32 types
        # no idea what is going on - removed until this can be solved
        # po=numpy.get_printoptions()
        # numpy.set_printoptions(precision=2, threshold=20, linewidth=1000, edgeitems=4)
        logger.info('computed  std vector of length %d' % std_vector.shape[1] )
        logger.info('  std: %s' % std_vector)
        # restore the print options
        # numpy.set_printoptions(po)

        self.std_vector = std_vector

        return  std_vector
test_formatters.py 文件源码 项目:leetcode 作者: thomasyimgit 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def test_precision():
    """test various values for float_precision."""
    f = PlainTextFormatter()
    nt.assert_equal(f(pi), repr(pi))
    f.float_precision = 0
    if numpy:
        po = numpy.get_printoptions()
        nt.assert_equal(po['precision'], 0)
    nt.assert_equal(f(pi), '3')
    f.float_precision = 2
    if numpy:
        po = numpy.get_printoptions()
        nt.assert_equal(po['precision'], 2)
    nt.assert_equal(f(pi), '3.14')
    f.float_precision = '%g'
    if numpy:
        po = numpy.get_printoptions()
        nt.assert_equal(po['precision'], 2)
    nt.assert_equal(f(pi), '3.14159')
    f.float_precision = '%e'
    nt.assert_equal(f(pi), '3.141593e+00')
    f.float_precision = ''
    if numpy:
        po = numpy.get_printoptions()
        nt.assert_equal(po['precision'], 8)
    nt.assert_equal(f(pi), repr(pi))
parameters.py 文件源码 项目:phoebe2 作者: phoebe-project 项目源码 文件源码 阅读 27 收藏 0 点赞 0 评论 0
def __repr__(self):
        """
        FloatArrayParameter needs to "truncate" the array by temporarily
        overriding np.set_printoptions
        """
        opt = np.get_printoptions()
        # <Parameter:_qualifier= takes 13+len(qualifier) characters
        np.set_printoptions(threshold=8, edgeitems=3, linewidth=opt['linewidth']-(13+len(self.qualifier)))
        repr_ = super(FloatArrayParameter, self).__repr__()
        np.set_printoptions(**opt)
        return repr_
parameters.py 文件源码 项目:phoebe2 作者: phoebe-project 项目源码 文件源码 阅读 38 收藏 0 点赞 0 评论 0
def __str__(self):
        """
        FloatArrayParameter needs to "truncate" the array by temporarily
        overriding np.set_printoptions
        """
        opt = np.get_printoptions()
        # Value:_ takes 7 characters
        np.set_printoptions(threshold=8, edgeitems=3, linewidth=opt['linewidth']-7)
        str_ = super(FloatArrayParameter, self).__str__()
        np.set_printoptions(**opt)
        return str_
parameters.py 文件源码 项目:phoebe2 作者: phoebe-project 项目源码 文件源码 阅读 28 收藏 0 点赞 0 评论 0
def to_string_short(self):
        """
        see also :meth:`to_string`

        :return: a shorter abreviated string reprentation of the parameter
        """
        opt = np.get_printoptions()
        np.set_printoptions(threshold=8, edgeitems=3, linewidth=opt['linewidth']-len(self.uniquetwig)-2)
        str_ = super(FloatArrayParameter, self).to_string_short()
        np.set_printoptions(**opt)
        return str_
parameters.py 文件源码 项目:phoebe2 作者: phoebe-project 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def __repr__(self):
        """
        IntArrayParameter needs to "truncate" the array by temporarily
        overriding np.set_printoptions
        """
        opt = np.get_printoptions()
        # <Parameter:_qualifier= takes 13+len(qualifier) characters
        np.set_printoptions(threshold=8, edgeitems=3, linewidth=opt['linewidth']-(13+len(self.qualifier)))
        repr_ = super(IntArrayParameter, self).__repr__()
        np.set_printoptions(**opt)
        return repr_
parameters.py 文件源码 项目:phoebe2 作者: phoebe-project 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
def __str__(self):
        """
        IntArrayParameter needs to "truncate" the array by temporarily
        overriding np.set_printoptions
        """
        opt = np.get_printoptions()
        # Value:_ takes 7 characters
        np.set_printoptions(threshold=8, edgeitems=3, linewidth=opt['linewidth']-7)
        str_ = super(IntArrayParameter, self).__str__()
        np.set_printoptions(**opt)
        return str_
test_arrayprint.py 文件源码 项目:krpcScripts 作者: jwvanderbeck 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
def setUp(self):
        self.oldopts = np.get_printoptions()
label_composer.py 文件源码 项目:world_merlin 作者: pbaljeka 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
def printoptions(*args, **kwargs):
    original = numpy.get_printoptions()
    numpy.set_printoptions(*args, **kwargs)
    yield 
    numpy.set_printoptions(**original)
min_max_norm.py 文件源码 项目:world_merlin 作者: pbaljeka 项目源码 文件源码 阅读 26 收藏 0 点赞 0 评论 0
def find_min_max_values(self, in_file_list):

        logger = logging.getLogger("acoustic_norm")

        file_number = len(in_file_list)
        min_value_matrix = numpy.zeros((file_number, self.feature_dimension))
        max_value_matrix = numpy.zeros((file_number, self.feature_dimension))
        io_funcs = BinaryIOCollection()
        for i in xrange(file_number):
            features = io_funcs.load_binary_file(in_file_list[i], self.feature_dimension)

            temp_min = numpy.amin(features, axis = 0)
            temp_max = numpy.amax(features, axis = 0)

            min_value_matrix[i, ] = temp_min;
            max_value_matrix[i, ] = temp_max;

        self.min_vector = numpy.amin(min_value_matrix, axis = 0)
        self.max_vector = numpy.amax(max_value_matrix, axis = 0)
        self.min_vector = numpy.reshape(self.min_vector, (1, self.feature_dimension))
        self.max_vector = numpy.reshape(self.max_vector, (1, self.feature_dimension))

        # po=numpy.get_printoptions()
        # numpy.set_printoptions(precision=2, threshold=20, linewidth=1000, edgeitems=4)
        logger.info('across %d files found min/max values of length %d:' % (file_number,self.feature_dimension) )
        logger.info('  min: %s' % self.min_vector)
        logger.info('  max: %s' % self.max_vector)
        # restore the print options
        # numpy.set_printoptions(po)


问题


面经


文章

微信
公众号

扫码关注公众号