latte.functional.interpolatability.monotonicity

Module Contents

Functions

monotonicity(z: numpy.ndarray, a: numpy.ndarray, reg_dim: Optional[List] = None, liad_mode: str = 'forward', reduce_mode: str = 'attribute', liad_thresh: float = 0.001, degenerate_val: float = np.nan, nanmean: bool = True) → numpy.ndarray

Calculate latent monotonicity.

latte.functional.interpolatability.monotonicity.monotonicity(z: numpy.ndarray, a: numpy.ndarray, reg_dim: Optional[List] = None, liad_mode: str = 'forward', reduce_mode: str = 'attribute', liad_thresh: float = 0.001, degenerate_val: float = np.nan, nanmean: bool = True) numpy.ndarray

Calculate latent monotonicity.

Parameters
  • z (np.ndarray, (n_samples, n_interp) or (n_samples, n_features or n_attributes, n_interp)) – a batch of latent vectors

  • a (np.ndarray, (n_samples, n_interp) or (n_samples, n_attributes, n_interp)) – a batch of attribute(s)

  • reg_dim (Optional[List], optional) – regularized dimensions, by default None Attribute a[:, i] is regularized by z[:, reg_dim[i]]. If None, a[:, i] is assumed to be regularized by z[:, i].

  • liad_mode (str, optional) – options for calculating LIAD, by default “forward”. Only “forward” is currently supported.

  • reduce_mode (str, optional) – options for reduction of the return array, by default “attribute”. Must be one of {“attribute”, “samples”, “all”, “none”}. If “all”, returns a scalar. If “attribute”, an average is taken along the sample axis and the return array is of shape (n_attributes,). If “samples”, an average is taken along the attribute axis and the return array is of shape (n_samples,). If “none”, returns a smoothness matrix of shape (n_samples, n_attributes,).

  • liad_thresh (float, optional) – threshold for ignoring noisy 1st order LIAD, by default 1e-3

  • degenerate_val (float, optional) – fill value for samples with all noisy LIAD (i.e., absolute value below liad_thresh), by default np.nan. Another possible option is to set this to 0.0.

  • nanmean (bool, optional) – whether to ignore the NaN values in calculating the return array, by default True. Ignored if reduce_mode is “none”. If all LIAD in an axis are NaNs, the return array in that axis is filled with NaNs.

Returns

monotonicity array. See reduce mode for return shape.

Return type

np.ndarray

References

1
    1. Watcharasupat, “Controllable Music: Supervised Learning of Disentangled Representations for Music Generation”, 2021.