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) 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 >>> ica = diffsptk.IndependentComponentAnalysis(order=1, n_comp=2, n_iter=10) >>> x = diffsptk.ramp(1, 6).view(-1, 2) >>> x tensor([[1., 2.], [3., 4.], [5., 6.]]) >>> W = ica(x) >>> W tensor([[ 0.9928, 0.0292], [-0.0844, 2.8666]]) >>> s = ica.transform(x) >>> s tensor([[ 1.2169, -0.0138], [ 0.0000, 0.0000], [-1.2169, 0.0138]])
See also