Transcript
Page 1: SPARSE TENSORS DECOMPOSITION SOFTWARE

04/19/23 1

SPARSE TENSORS DECOMPOSITION SOFTWARE

Papa S. Diaw, Master’s Candidate

Dr. Michael W. Berry, Major Professor

Page 2: SPARSE TENSORS DECOMPOSITION SOFTWARE

04/19/23 2

Introduction

• Large data sets

• Nonnegative Matrix Factorization (NMF)

Insights on the hidden relationships

Arrange multi-way data into a matrix• Computation memory and higher CPU • Linear relationships in the matrix representation• Failure to capture important structure information• Slower or less accurate calculations

Page 3: SPARSE TENSORS DECOMPOSITION SOFTWARE

04/19/23 3

Introduction (cont'd)

• Nonnegative Tensor Factorizations (NTF)

Natural way for high dimensionality

Original multi-way structure of the data

Image processing, text mining

Page 4: SPARSE TENSORS DECOMPOSITION SOFTWARE

04/19/23 4

Tensor Toolbox For MATLAB

• Sandia National Laboratories

• Licenses

• Proprietary Software

Page 5: SPARSE TENSORS DECOMPOSITION SOFTWARE

04/19/23 5

Motivation of the PILOT

• Python Software for NTF

• Alternative to Tensor Toolbox for MATLAB

• Incorporation into FutureLens

• Exposure to NTF

• Interest in the open source community

Page 6: SPARSE TENSORS DECOMPOSITION SOFTWARE

04/19/23 6

Tensors

• Multi-way array • Order/Mode/Ways• High-order• Fiber• Slice• Unfolding

Matricization or flattening Reordering the elements of an N-th order tensor into a matrix. Not unique

Page 7: SPARSE TENSORS DECOMPOSITION SOFTWARE

04/19/23 7

Tensors (cont’d)

• Kronecker Product

• Khatri-Rao product A⊙B=[a1⊗b1 a2⊗b2… aJ⊗bJ]

A⊗B =

a11B a12B K a1JB

a21B a22B K a2JB

M M O M

aI1B aI 2B K aIJB

⎜ ⎜ ⎜ ⎜

⎟ ⎟ ⎟ ⎟

Page 8: SPARSE TENSORS DECOMPOSITION SOFTWARE

04/19/23 8

Tensor Factorization

• Hitchcock in 1927 and later developed by Cattell in 1944 and Tucker in 1966

• Rewrite a given tensor as a finite sum of lower-rank tensors.

• Tucker and PARAFAC

• Rank Approximation is a problem

Page 9: SPARSE TENSORS DECOMPOSITION SOFTWARE

04/19/23 9

PARAFAC

• Parallel Factor Analysis

• Canonical Decomposition (CANDE-COMPE)

• Harsman,Carroll and Chang, 1970

Page 10: SPARSE TENSORS DECOMPOSITION SOFTWARE

04/19/23 10

PARAFAC (cont’d)

• Given a three-way tensor X and an approximation rank R, we define the factor matrices as the combination of the vectors from the rank-one components.

X ≈ A oB oC = ar obr ocrr=1

R

Page 11: SPARSE TENSORS DECOMPOSITION SOFTWARE

04/19/23 11

PARAFAC (cont’d)

Page 12: SPARSE TENSORS DECOMPOSITION SOFTWARE

04/19/23 12

PARAFAC (cont’d)

• Alternating Least Square (ALS)• We cycle “over all the factor matrices and performs a

least-square update for one factor matrix while holding all the others constant.”[7]

• NTF can be considered an extension of the PARAFAC model with the constraint of nonnegativity

Page 13: SPARSE TENSORS DECOMPOSITION SOFTWARE

04/19/23 13

Python

• Object-oriented, Interpreted

• Runs on all systems

• Flat learning curve

• Supports object methods (everything is an object in Python)

Page 14: SPARSE TENSORS DECOMPOSITION SOFTWARE

04/19/23 14

Python (cont’d)

• Recent interest in the scientific community

• Several scientific computing packages Numpy Scipy

• Python is extensible

Page 15: SPARSE TENSORS DECOMPOSITION SOFTWARE

04/19/23 15

Data Structures

• Dictionary

Store the tensor data

Mutable type of container that can store any number of Python objects

Pairs of keys and their corresponding values• Suitable for sparseness of our tensors

• VAST 2007 contest data 1,385,205,184 elements, with 1,184,139 nz

• Stores the nonzero elements and keeps track of the zeros by using the default value of the dictionary

Page 16: SPARSE TENSORS DECOMPOSITION SOFTWARE

04/19/23 16

Data Structures (cont’d)

• Numpy Arrays

Fundamental package for scientific computing in Python

Khatri-Rao products or tensors multiplications

Speed

Page 17: SPARSE TENSORS DECOMPOSITION SOFTWARE

04/19/23 17

Modules

Page 18: SPARSE TENSORS DECOMPOSITION SOFTWARE

04/19/23 18

Modules (cont’d)

• SPTENSOR

Most important module

Class (subscripts of nz, values)

• Flexibility (Numpy Arrays, Numpy Matrix, Python Lists)

Dictionary Keeps a few instances variables

• Size • Number of dimensions • Frobenius norm (Euclidean Norm)

Page 19: SPARSE TENSORS DECOMPOSITION SOFTWARE

04/19/23 19

Modules (cont’d)

• PARAFAC coordinates the NTF

Implementation of ALS

Convergence or the maximum number of iterations

Factor matrices are turned into a Kruskal Tensor

Page 20: SPARSE TENSORS DECOMPOSITION SOFTWARE

04/19/23 20

Modules (cont’d)

Page 21: SPARSE TENSORS DECOMPOSITION SOFTWARE

04/19/23 21

Modules (cont’d)

Page 22: SPARSE TENSORS DECOMPOSITION SOFTWARE

04/19/23 22

Modules (cont’d)

• INNERPROD Inner product between SPTENSOR and KTENSOR PARAFAC to compute the residual norm Kronecker product for matrices

• TTV Product sparse tensor with a (column) vector Returns a tensor

• Workhorse of our software package• Most computation• It is called by the MTTKRP and INNERPROD modules

Page 23: SPARSE TENSORS DECOMPOSITION SOFTWARE

04/19/23 23

Modules (cont’d)

• MTTKRP Khatri-Rao product off all factor matrices except the one

being updated Matrix multiplication of the matricized tensor with KR

product obtained above

• Ktensor Kruskal tensor Object returned after the factorization is done and the factor

matrices are normalized. Class

• Instance variables such as the Norm. • Norm of ktensor plays a big part in determining the residual norm in the

PARAFAC module.

Page 24: SPARSE TENSORS DECOMPOSITION SOFTWARE

04/19/23 24

Performance

• Python Profiler

Run time performance

Tool for detecting bottlenecks

Code optimization• negligible improvement • efficiency loss in some modules

Page 25: SPARSE TENSORS DECOMPOSITION SOFTWARE

04/19/23 25

Performance (cnt’d)

• Lists and Recursions

ncalls tottime percall cumtime Percall function 2803 3605.732 1.286 3605.732 1.286 tolist 1400 1780.689 1.272 2439.986 1.743 return_unique 9635 1538.597 0.160 1538.597 0.160 array 814018498 651.952 0.000 651.952 0.000 get of 'dict' 400 101.308 0.072 140.606 0.100 setup_size 1575/700 81.705 0.052 7827.373 11.182 ttv 2129 39.287 0.018 39.287 0.018 max

Page 26: SPARSE TENSORS DECOMPOSITION SOFTWARE

04/19/23 26

Performance (cnt’d)

• Numpy Arrays

ncalls tottime percall cumtime Percall function 1800 15571.118 8.651 16798.194 9.332 return_unique 12387 2306.950 0.186 2306.950 0.186 array 1046595156 1191.479 0.000 1191.479 0.000 'get' of 'dict' 1800 1015.757 0.564 1086.062 0.603 setup_size 2025/900 358.778 0.177 20589.563 22.877 ttv 2734 69.638 0.025 69.638 0.025 max

Page 27: SPARSE TENSORS DECOMPOSITION SOFTWARE

04/19/23 27

Performance (cnt’d)

• After removing Recursions

ncalls tottime percall cumtime Percall function 75 134.939 1.799 135.569 1.808 myaccumarray 75 7.802 0.104 8.148 0.109 setup_dic 100 5.463 0.055 151.402 1.514 ttv 409 2.043 0.005 2.043 0.005 array 1 1.034 1.034 1.034 1.034 get_norm 962709 0.608 0.000 0.608 0.000 append 479975 0.347 0.000 0.347 0.000 item 3 0.170 0.057 150.071 50.024 mttkrp 25 0.122 0.005 0.122 0.005 sum (Numpy) 87 0.083 0.001 0.083 0.001 dot

Page 28: SPARSE TENSORS DECOMPOSITION SOFTWARE

04/19/23 28

Floating-Point Arithmetic

• Binary floating-point

“Binary floating-point cannot exactly represent decimal fractions, so if binary floating-point is used it is not possible to guarantee that results will be the same as those using decimal arithmetic.”[12]

Makes the iterations volatile

Page 29: SPARSE TENSORS DECOMPOSITION SOFTWARE

04/19/23 29

Convergence Issues

TOL = Tolerance on the difference in fit

P = KTENSOR

X = SPTENSOR

RN = normX 2 + normP 2 − 2 * INNERPROD(X,P)

Fiti =1 − (RN /normX)

ΔFit = Fiti − Fiti−1

if (ΔFit < TOL)

STOP

else

Continue

Page 30: SPARSE TENSORS DECOMPOSITION SOFTWARE

04/19/23 30

Convergence Issues (ctn’d)

Page 31: SPARSE TENSORS DECOMPOSITION SOFTWARE

04/19/23 31

Convergence Issues (cont’d)

Page 32: SPARSE TENSORS DECOMPOSITION SOFTWARE

04/19/23 32

Conclusion

• There is still work to do after NTF Preprocessing of data

Post Processing of results such as FutureLens• Expertise

• Extract and Identify hidden components

• Tucker Implementation.

• C extension to increase speed.

• GUI

Page 33: SPARSE TENSORS DECOMPOSITION SOFTWARE

04/19/23 33

Acknowledgments

• Mr. Andrey Puretskiy Discussions at all stages of the PILOT Consultancy in text mining Testing

• Tensor Toolbox For MATLAB (Bader and Kolda) Understanding of tensor Decomposition PARAFAC

Page 34: SPARSE TENSORS DECOMPOSITION SOFTWARE

04/19/23 34

References

1) http://csmr.ca.sandia.gov/~tgkolda/TensorToolbox/2) Tamara G. Kolda, Brett W. Bader , “Tensor Decompostions and Applications”,

SIAM Review , June 10, 2008.3) Andrzej Cichocki, Rafal Zdunek, Anh Huy Phan, Shun-ichi Amari, “Nonnegative

Matrix and Tensor Factorizations”, John Wiley & Sons, Ltd, 1009.4) http://docs.python.org/library/profile.html5) http://www.mathworks.com/access/helpdesk/help/techdoc6) http://www.scipy.org/NumPy_for_Matlab_Users7) Brett W. Bader, Andrey A. Puretskiy, Michael W. Berry, “Scenario Discovery Using

Nonnegative Tensor Factorization”, J. Ruiz-Schulcloper and W.G. Kropatsch (Eds.): CIARP 2008, LNCS 5197, pp.791-805, 2008

8) http://docs.scipy.org/doc/numpy/user/9) http://docs.scipy.org/doc/10) http://docs.scipy.org/doc/numpy/user/whatisnumpy.html11) Tamara G. Kolda, “Multilinear operators for higher-order decompositions”, SANDIA

REPORT, April 200612) http://speleotrove.com/decimal/decifaq1.html#inexact

Page 35: SPARSE TENSORS DECOMPOSITION SOFTWARE

04/19/23 35

QUESTIONS?


Top Related