The hardware and bandwidth for this mirror is donated by METANET, the Webhosting and Full Service-Cloud Provider.
If you wish to report a bug, or if you are interested in having us mirror your free-software or open-source project, please feel free to contact us at mirror[@]metanet.ch.
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")
## Warning: no DISPLAY variable so Tk is not available
##
## Attaching package: 'nnTensor'
## The following object is masked from 'package:iTensor':
##
## toyModel
<- nnTensor::toyModel("CP")
data str(data, 2)
## Formal class 'Tensor' [package "rTensor"] with 3 slots
## ..@ num_modes: int 3
## ..@ modes : int [1:3] 30 30 30
## ..@ data : num [1:30, 1:30, 1:30] 113 81 120 95 102 2 4 2 0 1 ...
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 (Vasilescu 2005)).
MultilinearICA
can be performed as follows.
<- MultilinearICA(data, Js=c(4,4,4), algorithm="FastICA") out
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.
<- recTensor(out$S, out$As)
rec_data plotTensor3D(rec_data)
## R version 4.3.0 (2023-04-21)
## Platform: x86_64-pc-linux-gnu (64-bit)
## Running under: Debian GNU/Linux bookworm/sid
##
## Matrix products: default
## BLAS: /usr/lib/x86_64-linux-gnu/openblas-pthread/libblas.so.3
## LAPACK: /usr/lib/x86_64-linux-gnu/openblas-pthread/libopenblasp-r0.3.21.so; LAPACK version 3.11.0
##
## locale:
## [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C
## [3] LC_TIME=en_US.UTF-8 LC_COLLATE=en_US.UTF-8
## [5] LC_MONETARY=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8
## [7] LC_PAPER=en_US.UTF-8 LC_NAME=C
## [9] LC_ADDRESS=C LC_TELEPHONE=C
## [11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C
##
## time zone: Etc/UTC
## tzcode source: system (glibc)
##
## attached base packages:
## [1] stats graphics grDevices utils datasets methods base
##
## other attached packages:
## [1] nnTensor_1.1.13 mixOmics_6.24.0 ggplot2_3.4.2 lattice_0.21-8
## [5] MASS_7.3-59 iTensor_1.0.2
##
## loaded via a namespace (and not attached):
## [1] dotCall64_1.0-2 spam_2.9-1 gtable_0.3.3
## [4] ellipse_0.4.5 xfun_0.39 bslib_0.4.2
## [7] tagcloud_0.6 ggrepel_0.9.3 vctrs_0.6.2
## [10] tools_4.3.0 generics_0.1.3 parallel_4.3.0
## [13] tibble_3.2.1 fansi_1.0.4 highr_0.10
## [16] rARPACK_0.11-0 pkgconfig_2.0.3 Matrix_1.5-4
## [19] RColorBrewer_1.1-3 lifecycle_1.0.3 groupICA_0.1.1
## [22] compiler_4.3.0 stringr_1.5.0 fields_14.1
## [25] munsell_0.5.0 codetools_0.2-19 misc3d_0.9-1
## [28] einsum_0.1.0 htmltools_0.5.5 maps_3.4.1
## [31] sass_0.4.5 yaml_2.3.7 pillar_1.9.0
## [34] jquerylib_0.1.4 tidyr_1.3.0 BiocParallel_1.34.0
## [37] cachem_1.0.7 viridis_0.6.2 nlme_3.1-162
## [40] RSpectra_0.16-1 tidyselect_1.2.0 digest_0.6.31
## [43] stringi_1.7.12 dplyr_1.1.2 reshape2_1.4.4
## [46] purrr_1.0.1 splines_4.3.0 fastmap_1.1.1
## [49] grid_4.3.0 colorspace_2.1-0 cli_3.6.1
## [52] rTensor_1.4.8 magrittr_2.0.3 utf8_1.2.3
## [55] corpcor_1.6.10 withr_2.5.0 scales_1.2.1
## [58] plot3D_1.4 rmarkdown_2.21 matrixStats_0.63.0
## [61] igraph_1.4.2 gridExtra_2.3 evaluate_0.20
## [64] knitr_1.42 tcltk_4.3.0 viridisLite_0.4.1
## [67] mgcv_1.8-42 jointDiag_0.4 rlang_1.1.0
## [70] Rcpp_1.0.10 glue_1.6.2 geigen_2.3
## [73] jsonlite_1.8.4 R6_2.5.1 plyr_1.8.8
These binaries (installable software) and packages are in development.
They may not be fully stable and should be used with caution. We make no claims about them.