nnmnkwii.util.meanstd

nnmnkwii.util.meanstd(dataset, lengths=None)[source]

Mean/std-deviation computation given a iterable dataset

Dataset can have variable length samples. In that cases, you need to explicitly specify lengths for all the samples.

Parameters:
Returns:

Mean and variance for each dimention.

Return type:

tuple

Examples

>>> from nnmnkwii.util import meanstd
>>> from nnmnkwii.util import example_file_data_sources_for_acoustic_model
>>> from nnmnkwii.datasets import FileSourceDataset
>>> X, Y = example_file_data_sources_for_acoustic_model()
>>> X, Y = FileSourceDataset(X), FileSourceDataset(Y)
>>> lengths = [len(y) for y in Y]
>>> data_mean, data_std = meanstd(Y, lengths)