latte.functional.interpolatability.smoothness

Module Contents

Functions

smoothness(z: numpy.ndarray, a: numpy.ndarray, reg_dim: Optional[List] = None, liad_mode: str = 'forward', max_mode: str = 'lehmer', ptp_mode: Union[float, str] = 'naive', reduce_mode: str = 'attribute', clamp: bool = False, p: float = 2.0) → numpy.ndarray

Calculate latent smoothness.

latte.functional.interpolatability.smoothness.smoothness(z: numpy.ndarray, a: numpy.ndarray, reg_dim: Optional[List] = None, liad_mode: str = 'forward', max_mode: str = 'lehmer', ptp_mode: Union[float, str] = 'naive', reduce_mode: str = 'attribute', clamp: bool = False, p: float = 2.0) numpy.ndarray

Calculate latent smoothness.

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.

  • max_mode (str, optional) – options for calculating array maximum of 2nd order LIAD, by default “lehmer”. Must be one of {“lehmer”, “naive”}. If “lehmer”, the maximum is calculated using the Lehmer mean with power p. If “naive”, the maximum is calculated using the naive array maximum.

  • ptp_mode (str, optional) – options for calculating range of 1st order LIAD for normalization, by default “naive”. Must be either “naive” or a float value in (0.0, 1.0]. If “naive”, the range is calculated using the naive peak-to-peak range. If float, the range is taken to be the range between quantile 0.5-0.5*ptp_mode and quantile 0.5+0.5*ptp_mode.

  • 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,).

  • clamp (bool, optional) – Whether to clamp smoothness to [0, 1], by default False

  • p (float, optional) – Lehmer mean power, by default 2.0 (i.e., contraharmonic mean). Only used if max_mode == “lehmer”. Must be greater than 1.0.

Returns

smoothness 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.