nnmnkwii.util.adjast_frame_length

nnmnkwii.util.adjast_frame_length(x, y, pad=True, ensure_even=False)[source]

Adjast frame lengths given two feature matrices.

This ensures that two feature matrices have same number of frames, by padding zeros to the end or removing last frames.

Parameters:
  • x (ndarray) – Input 2d feature matrix, shape (T^1 x D).
  • y (ndarray) – Input 2d feature matrix, shape (T^2 x D).
  • pad (bool) – If True, pads zeros to the end, otherwise removes last few frames to ensure same frame lengths.
  • ensure_even (bool) – If True, ensure number of frames to be even number.
Returns:

Pair of adjasted feature matrices, of each shape (T x D).

Return type:

Tuple

Examples

>>> from nnmnkwii.util import adjast_frame_length
>>> import numpy as np
>>> x = np.zeros((10, 1))
>>> y = np.zeros((11, 1))
>>> x, y = adjast_frame_length(x, y)
>>> assert len(x) == len(y)