ica#
- diffsptk.ICA#
alias of
IndependentComponentAnalysis
- class diffsptk.IndependentComponentAnalysis(order: int, n_comp: int, *, func: str = 'logcosh', n_iter: int = 100, eps: float = 0.0001, batch_size: int | None = None, seed: int | None = None, verbose: bool = False, device: device | None = None, dtype: dtype | None = None)[source]#
Independent component analysis module. Note that the forward method is not differentiable.
- Parameters:
- orderint >= 0
The order of the vector, \(M\).
- n_compint >= 1
The number of components, \(K\).
- func[‘logcosh’, ‘gauss’]
The nonquadratic function used in the approximation of negentropy.
- n_iterint >= 1
The number of iterations.
- epsfloat >= 0
The convergence threshold.
- batch_sizeint >= 1 or None
The batch size.
- seedint or None
The random seed.
- verbosebool
If True, shows progress bars.
- devicetorch.device or None
The device of this module.
- dtypetorch.dtype or None
The data type of this module.
References
[1]A. Hyvarinen and E. Oja, “Independent component analysis: algorithms and applications,” Neural Networks, vol. 13, pp. 411-430, 2000.
- forward(x: Tensor | DataLoader) Tensor[source]#
Perform independent component analysis.
- Parameters:
- xTensor [shape=(T, M+1)] or DataLoader
The input vectors or a DataLoader that yields the input vectors.
- Returns:
- WTensor [shape=(K, K)]
The separating matrix.
Examples
>>> import diffsptk >>> import torch >>> ica = diffsptk.IndependentComponentAnalysis(order=1, n_comp=2, n_iter=10) >>> x = torch.tensor([[1.0, 2.0], [3.0, 1.0], [2.0, 5.0], [6.0, 4.0]]) >>> W = ica(x) >>> W tensor([[ 0.8143, 0.5805], [-0.5805, 0.8143]]) >>> s = ica.transform(x) >>> s tensor([[ 0.8966, -0.6918], [ 1.0956, 0.7138], [-0.9212, -1.2381], [-1.0710, 1.2161]])
See also