nnmnkwii.util.meanvar

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

Mean/variance 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 meanvar
>>> 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_var = meanvar(Y, lengths)