In this vignette we consider approximating a tensor as a product of multiple low-rank matrices (a.k.a., factor matrices) and a core tensor.
Test data is available from toyModel
.
library("iTensor") library("nnTensor") data <- nnTensor::toyModel("CP") str(data, 2)
You will see that there are four small blocks in the diagonal direction of the data tensor.
plotTensor3D(data)
There are so many tensor decomposition algorithms but here we consider that each factor matrix is extracted by Independent Component Analysis (ICA). This is called Multilinear Independent Component Analysis (MultilinearICA [@multilinearica]).
MultilinearICA
can be performed as follows.
out <- MultilinearICA(data, Js=c(4,4,4), algorithm="FastICA")
The rank for each factor matrix can be set as Js
and the decomposition algorithm can be easily switched by algorithm
.
By using recTensor
of nnTensor
, user can easily reconstruct the data from core tensor and factor matrices as follows.
rec_data <- recTensor(out$S, out$As) plotTensor3D(rec_data)
sessionInfo()
Any scripts or data that you put into this service are public.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.