Tensor sketch

Short description: Algorithm for reducing the dimension of tensors

Machine learning and
data mining

Problems

* Classification
* Clustering
* Regression
* Anomaly detection
* AutoML
* Association rules
* Reinforcement learning
* Structured prediction
* Feature engineering
* Feature learning
* Online learning
* Semi-supervised learning
* Unsupervised learning
* Learning to rank
* Grammar induction

Supervised learning
(classification • regression)

* Decision trees
* Ensembles
* Bagging
* Boosting
* Random forest
* k-NN
* Linear regression
* Naive Bayes
* Artificial neural networks
* Logistic regression
* Perceptron
* Relevance vector machine (RVM)
* Support vector machine (SVM)

Clustering

* BIRCH
* CURE
* Hierarchical
* k-means
* Expectation–maximization (EM)

DBSCAN
* OPTICS
* Mean-shift

Dimensionality reduction

* Factor analysis
* CCA
* ICA
* LDA
* NMF
* PCA
* t-SNE

Structured prediction

* Graphical models
* Bayes net
* Conditional random field
* Hidden Markov

Anomaly detection

* k-NN
* Local outlier factor

Artificial neural networks

* Autoencoder
* Deep learning
* DeepDream
* Multilayer perceptron
* RNN
* LSTM
* GRU
* Restricted Boltzmann machine
* GAN
* SOM
* Convolutional neural network
* U-Net

Reinforcement learning

* Q-learning
* SARSA
* Temporal difference (TD)

Theory

* Bias–variance dilemma
* Computational learning theory
* Empirical risk minimization
* Occam learning
* PAC learning
* Statistical learning
* VC theory

Machine-learning venues

* NeurIPS
* ICML
* ML
* JMLR
* ArXiv:cs.LG

Glossary of artificial intelligence

* Glossary of artificial intelligence

Related articles

* List of datasets for machine-learning research
* Outline of machine learning

* v
* t
* e

In statistics, machine learning and algorithms, a tensor sketch is a type of dimensionality reduction that is particularly efficient when applied to vectors that have tensor structure.[1][2] Such a sketch can be used to speed up explicit kernel methods, bilinear pooling in neural networks and is a cornerstone in many numerical linear algebra algorithms.[3]

## Contents

* 1 Mathematical definition
* 2 History
* 3 Tensor random projections
* 3.1 Construction with fast Fourier transform
* 3.2 Application to general matrices
* 4 Variations
* 4.1 Recursive construction
* 4.2 Fast constructions
* 5 Data aware sketching
* 6 Applications
* 6.1 Explicit polynomial kernels
* 6.2 Compressed matrix multiplication
* 6.3 Compact multilinear pooling
* 7 References
* 8 Further reading

## Mathematical definition

Mathematically, a dimensionality reduction or sketching matrix is a matrix M∈ℝk×d, where k<d, such that for any vector x∈ℝd

|‖Mx‖2−‖x‖2|<ε‖x‖2

with high probability. In other words, M preserves the norm of vectors up to a small error.

A tensor sketch has the extra property that if x=y⊗z for some vectors y∈ℝd1,z∈ℝd2 such that d1d2=d, the transformation M(y⊗z) can be computed more efficiently. Here ⊗ denotes the Kronecker product, rather than the outer product, though the two are related by a flattening.

The speedup is achieved by first rewriting M(y⊗z)=M′y∘M″z, where ∘ denotes the elementwise (Hadamard) product. Each of M′y and M″z can be computed in time O(kd1) and O(kd2), respectively; including the Hadamard product gives overall time O(d1d2+kd1+kd2). In most use cases this method is significantly faster than the full M(y⊗z) requiring O(kd)=O(kd1d2) time.

For higher-order tensors, such as x=y⊗z⊗t, the savings are even more impressive.

## History

The term tensor sketch was coined in 2013[4] describing a technique by Rasmus Pagh[5] from the same year. Originally it was understood using the fast Fourier transform to do fast convolution of count sketches. Later research works generalized it to a much larger class of dimensionality reductions via Tensor random embeddings.

Tensor random embeddings were introduced in 2010 in a paper[6] on differential privacy and were first analyzed by Rudelson et al. in 2012 in the context of sparse recovery.[7]

Avron et al.[8] were the first to study the subspace embedding properties of tensor sketches, particularly focused on applications to polynomial kernels. In this context, the sketch is required not only to preserve the norm of each individual vector with a certain probability but to preserve the norm of all vectors in each individual linear subspace. This is a much stronger property, and it requires larger sketch sizes, but it allows the kernel methods to be used very broadly as explored in the book by David Woodruff.[3]

## Tensor random projections

The face-splitting product is defined as the tensor products of the rows (was proposed by V. Slyusar[9] in 1996[10][11][12][13][14] for radar and digital antenna array applications). More directly, let 𝐂∈ℝ3×3 and 𝐃∈ℝ3×3 be two matrices. Then the face-splitting product 𝐂∙𝐃 is[10][11][12][13] 𝐂∙𝐃=[𝐂1⊗𝐃1𝐂2⊗𝐃2𝐂3⊗𝐃3]=[𝐂1,1𝐃1,1𝐂1,1𝐃1,2𝐂1,1𝐃1,3𝐂1,2𝐃1,1𝐂1,2𝐃1,2𝐂1,2𝐃1,3𝐂1,3𝐃1,1𝐂1,3𝐃1,2𝐂1,3𝐃1,3𝐂2,1𝐃2,1𝐂2,1𝐃2,2𝐂2,1𝐃2,3𝐂2,2𝐃2,1𝐂2,2𝐃2,2𝐂2,2𝐃2,3𝐂2,3𝐃2,1𝐂2,3𝐃2,2𝐂2,3𝐃2,3𝐂3,1𝐃3,1𝐂3,1𝐃3,2𝐂3,1𝐃3,3𝐂3,2𝐃3,1𝐂3,2𝐃3,2𝐂3,2𝐃3,3𝐂3,3𝐃3,1𝐂3,3𝐃3,2𝐂3,3𝐃3,3]. The reason this product is useful is the following identity:

(𝐂∙𝐃)(x⊗y)=𝐂x∘𝐃y=[(𝐂x)1(𝐃y)1(𝐂x)2(𝐃y)2⋮],

where ∘ is the element-wise (Hadamard) product. Since this operation can be computed in linear time, 𝐂∙𝐃 can be multiplied on vectors with tensor structure much faster than normal matrices.

### Construction with fast Fourier transform

The tensor sketch of Pham and Pagh[4] computes C(1)x∗C(2)y, where C(1) and C(2) are independent count sketch matrices and ∗ is vector convolution. They show that, amazingly, this equals C(x⊗y) – a count sketch of the tensor product!

It turns out that this relation can be seen in terms of the face-splitting product as

C(1)x∗C(2)y=ℱ−1(ℱC(1)x∘ℱC(2)y), where ℱ is the Fourier transform matrix.

Since ℱ is an orthonormal matrix, ℱ−1 doesn't impact the norm of Cx and may be ignored. What's left is that C∼𝒞(1)∙𝒞(2).

On the other hand,

ℱ(C(1)x∗C(2)y)=ℱC(1)x∘ℱC(2)y=(ℱC(1)∙ℱC(2))(x⊗y).

### Application to general matrices

The problem with the original tensor sketch algorithm was that it used count sketch matrices, which aren't always very good dimensionality reductions.

In 2020[15] it was shown that any matrices with random enough independent rows suffice to create a tensor sketch. This allows using matrices with stronger guarantees, such as real Gaussian Johnson Lindenstrauss matrices.

In particular, we get the following theorem

Consider a matrix T with i.i.d. rows T1,…,Tm∈ℝd, such that E[(T1x)2]=‖x‖22 and E[(T1x)p]1/p≤ap‖x‖2. Let T(1),…,T(c) be independent consisting of T and M=T(1)∙…∙T(c).
Then |‖Mx‖2−‖x‖2|<ε‖x‖2 with probability 1−δ for any vector x if
m=(4a)2cε−2log⁡1/δ+(2ae)ε−1(log⁡1/δ)c.

In particular, if the entries of T are ±1 we get m=O(ε−2log⁡1/δ+ε−1(1clog⁡1/δ)c) which matches the normal Johnson Lindenstrauss theorem of m=O(ε−2log⁡1/δ) when ε is small.

The paper[15] also shows that the dependency on ε−1(1clog⁡1/δ)c is necessary for constructions using tensor randomized projections with Gaussian entries.

## Variations

### Recursive construction

Because of the exponential dependency on c in tensor sketches based on the face-splitting product, a different approach was developed in 2020[15] which applies

M(x⊗y⊗⋯)=M(1)(x⊗(M(2)y⊗⋯))

We can achieve such an M by letting

M=M(c)(M(c−1)⊗Id)(M(c−2)⊗Id2)⋯(M(1)⊗Idc−1).

With this method, we only apply the general tensor sketch method to order 2 tensors, which avoids the exponential dependency in the number of rows.

It can be proved[15] that combining c dimensionality reductions like this only increases ε by a factor c.

### Fast constructions

The fast Johnson–Lindenstrauss transform is a dimensionality reduction matrix

Given a matrix M∈ℝk×d, computing the matrix vector product Mx takes kd time. The Fast Johnson Lindenstrauss Transform (FJLT),[16] was introduced by Ailon and Chazelle in 2006.

A version of this method takes M=SHD where

1. D is a diagonal matrix where each diagonal entry Di,i is ±1 independently.

The matrix-vector multiplication Dx can be computed in O(d) time.

1. H is a Hadamard matrix, which allows matrix-vector multiplication in time O(dlog⁡d)
2. S is a k×d sampling matrix which is all zeros, except a single 1 in each row.

If the diagonal matrix is replaced by one which has a tensor product of ±1 values on the diagonal, instead of being fully independent, it is possible to compute SHD⁡(x⊗y) fast.

For an example of this, let ρ,σ∈{−1,1}2 be two independent ±1 vectors and let D be a diagonal matrix with ρ⊗σ on the diagonal. We can then split up SHD⁡(x⊗y) as follows:

SHD⁡(x⊗y)=[100000100100][11111−11−111−1−11−1−11][σ1ρ10000σ1ρ20000σ2ρ10000σ2ρ2][x1y1x2y1x1y2x2y2]=([100110]∙[101001])([111−1]⊗[111−1])([σ100σ2]⊗[ρ100ρ2])([x1x2]⊗[y1y2])=([100110]∙[101001])([111−1][σ100σ2][x1x2]⊗[111−1][ρ100ρ2][y1y2])=[100110][111−1][σ100σ2][x1x2]∘[101001][111−1][ρ100ρ2][y1y2].

In other words, SHD⁡=S(1)HD(1)∙S(2)HD(2), splits up into two Fast Johnson–Lindenstrauss transformations, and the total reduction takes time O(d1log⁡d1+d2log⁡d2) rather than d1d2log⁡(d1d2) as with the direct approach.

The same approach can be extended to compute higher degree products, such as SHD⁡(x⊗y⊗z)

Ahle et al.[15] shows that if SHD has ε−2(log⁡1/δ)c+1 rows, then |‖SHD⁡x‖2−‖x‖|≤ε‖x‖2 for any vector x∈ℝdc with probability 1−δ, while allowing fast multiplication with degree c tensors.

Jin et al.,[17] the same year, showed a similar result for the more general class of matrices call RIP, which includes the subsampled Hadamard matrices. They showed that these matrices allow splitting into tensors provided the number of rows is ε−2(log⁡1/δ)2c−1log⁡d. In the case c=2 this matches the previous result.

These fast constructions can again be combined with the recursion approach mentioned above, giving the fastest overall tensor sketch.

## Data aware sketching

It is also possible to do so-called "data aware" tensor sketching. Instead of multiplying a random matrix on the data, the data points are sampled independently with a certain probability depending on the norm of the point.[18]

## Applications

### Explicit polynomial kernels

Kernel methods are popular in machine learning as they give the algorithm designed the freedom to design a "feature space" in which to measure the similarity of their data points. A simple kernel-based binary classifier is based on the following computation:

y^(𝐱′)=sgn⁡∑i=1nyik(𝐱i,𝐱′),

where 𝐱i∈ℝd are the data points, yi is the label of the ith point (either −1 or +1), and y^(𝐱′) is the prediction of the class of 𝐱′. The function k:ℝd×ℝd->ℝ is the kernel. Typical examples are the radial basis function kernel, k(x,x′)=exp⁡(−‖x−x′‖22), and polynomial kernels such as k(x,x′)=(1+⟨x,x′⟩)2.

When used this way, the kernel method is called "implicit". Sometimes it is faster to do an "explicit" kernel method, in which a pair of functions f,g:ℝd->ℝD are found, such that k(x,x′)=⟨f(x),g(x′)⟩. This allows the above computation to be expressed as

y^(𝐱′)=sgn⁡∑i=1nyi⟨f(𝐱i),g(𝐱′)⟩=sgn⁡⟨(∑i=1nyif(𝐱i)),g(𝐱′)⟩,

where the value ∑i=1nyif(𝐱i) can be computed in advance.

The problem with this method is that the feature space can be very large. That is D>>d. For example, for the polynomial kernel k(x,x′)=⟨x,x′⟩3 we get f(x)=x⊗x⊗x and g(x′)=x′⊗x′⊗x′, where ⊗ is the tensor product and f(x),g(x′)∈ℝD where D=d3. If d is already large, D can be much larger than the number of data points (n) and so the explicit method is inefficient.

The idea of tensor sketch is that we can compute approximate functions f′,g′:ℝd->ℝt where t can even be smaller than d, and which still have the property that ⟨f′(x),g′(x′)⟩≈k(x,x′).

This method was shown in 2020[15] to work even for high degree polynomials and radial basis function kernels.

### Compressed matrix multiplication

Assume we have two large datasets, represented as matrices X,Y∈ℝn×d, and we want to find the rows i,j with the largest inner products ⟨Xi,Yj⟩. We could compute Z=XYT∈ℝn×n and simply look at all n2 possibilities. However, this would take at least n2 time, and probably closer to n2d using standard matrix multiplication techniques.

The idea of Compressed Matrix Multiplication is the general identity

XYT=∑i=1dXi⊗Yi

where ⊗ is the tensor product. Since we can compute a (linear) approximation to Xi⊗Yi efficiently, we can sum those up to get an approximation for the complete product.

### Compact multilinear pooling

Tensor sketches can be used to decrease the number of variables needed when implementing Bilinear Pooling in a neural network.

Bilinear pooling is the technique of taking two input vectors, x,y from different sources, and using the tensor product x⊗y as the input layer to a neural network.

In[19] the authors considered using tensor sketch to reduce the number of variables needed.

In 2017 another paper[20] takes the FFT of the input features, before they are combined using the element-wise product. This again corresponds to the original tensor sketch.

## References

1. ↑ "Low-rank Tucker decomposition of large tensors using: Tensor Sketch". Boulder, Colorado: University of Colorado Boulder. https://amath.colorado.edu/faculty/becker/TensorSketch.pdf.
2. ↑ Ahle, Thomas; Knudsen, Jakob (2019-09-03). "Almost Optimal Tensor Sketch". https://www.researchgate.net/publication/335617805.
3. ↑ 3.0 3.1 Woodruff, David P. "Sketching as a Tool for Numerical Linear Algebra ." Theoretical Computer Science 10.1-2 (2014): 1–157.
4. ↑ 4.0 4.1 Ninh, Pham (2013). "Fast and scalable polynomial kernels via explicit feature maps". SIGKDD international conference on Knowledge discovery and data mining. Association for Computing Machinery. doi:10.1145/2487575.2487591.
5. ↑ "Compressed matrix multiplication". ACM Transactions on Computation Theory (Association for Computing Machinery) 5 (3): 1–17. 2013. doi:10.1145/2493252.2493254.
6. ↑ Kasiviswanathan, Shiva Prasad, et al. "The price of privately releasing contingency tables and the spectra of random matrices with correlated rows ." Proceedings of the forty-second ACM symposium on Theory of computing. 2010.
7. ↑ Rudelson, Mark, and Shuheng Zhou. "Reconstruction from anisotropic random measurements ." Conference on Learning Theory. 2012.
8. ↑ Avron, Haim; Nguyen, Huy; Woodruff, David (2013). "Compressed matrix multiplication". ACM Transactions on Computation Theory (Association for Computing Machinery) 5 (3): 1–17. doi:10.1145/2493252.2493254.
9. ↑ Anna Esteve, Eva Boj & Josep Fortiana (2009): Interaction Terms in Distance-Based Regression, Communications in Statistics – Theory and Methods, 38:19, P. 3501 [1]
10. ↑ 10.0 10.1 Slyusar, V. I. (1998). "End products in matrices in radar applications.". Radioelectronics and Communications Systems 41 (3): 50–53. http://slyusar.kiev.ua/en/IZV_1998_3.pdf.
11. ↑ 11.0 11.1 Slyusar, V. I. (1997-05-20). "Analytical model of the digital antenna array on a basis of face-splitting matrix products.". Proc. ICATT-97, Kyiv: 108–109. http://slyusar.kiev.ua/ICATT97.pdf.
12. ↑ 12.0 12.1 Slyusar, V. I. (1997-09-15). "New operations of matrices product for applications of radars". Proc. Direct and Inverse Problems of Electromagnetic and Acoustic Wave Theory (DIPED-97), Lviv.: 73–74. http://slyusar.kiev.ua/DIPED_1997.pdf.
13. ↑ 13.0 13.1 Slyusar, V. I. (March 13, 1998). "A Family of Face Products of Matrices and its Properties". Cybernetics and Systems Analysis C/C of Kibernetika I Sistemnyi Analiz. – 1999. 35 (3): 379–384. doi:10.1007/BF02733426. http://slyusar.kiev.ua/FACE.pdf.
14. ↑ Slyusar, V. I. (2003). "Generalized face-products of matrices in models of digital antenna arrays with nonidentical channels". Radioelectronics and Communications Systems 46 (10): 9–17. http://slyusar.kiev.ua/en/IZV_2003_10.pdf.
15. ↑ 15.0 15.1 15.2 15.3 15.4 15.5 Ahle, Thomas; Kapralov, Michael; Knudsen, Jakob (2020). "Oblivious Sketching of High-Degree Polynomial Kernels". ACM-SIAM Symposium on Discrete Algorithms. Association for Computing Machinery. doi:10.1137/1.9781611975994.9.
16. ↑ Ailon, Nir; Chazelle, Bernard (2006). "Proceedings of the 38th Annual ACM Symposium on Theory of Computing". Proceedings of the 38th Annual ACM Symposium on Theory of Computing. New York: ACM Press. pp. 557–563. doi:10.1145/1132516.1132597. ISBN 1-59593-134-1.
17. ↑ Jin, Ruhui, Tamara G. Kolda, and Rachel Ward. "Faster Johnson–Lindenstrauss Transforms via Kronecker Products." arXiv preprint arXiv:1909.04801 (2019).
18. ↑ Wang, Yining; Tung, Hsiao-Yu; Smola, Alexander; Anandkumar, Anima. "Fast and Guaranteed Tensor Decomposition via Sketching". Advances in Neural Information Processing Systems 28 (NIPS 2015).
19. ↑ Gao, Yang, et al. "Compact bilinear pooling ." Proceedings of the IEEE conference on computer vision and pattern recognition. 2016.
20. ↑ Algashaam, Faisal M., et al. "Multispectral periocular classification with multimodal compact multi-linear pooling ." IEEE Access 5 (2017): 14572–14578.

## Further reading

* Ahle, Thomas; Knudsen, Jakob (2019-09-03). "Almost Optimal Tensor Sketch". https://www.researchgate.net/publication/335617805.
* Slyusar, V. I. (1998). "End products in matrices in radar applications.". Radioelectronics and Communications Systems 41 (3): 50–53. http://slyusar.kiev.ua/en/IZV_1998_3.pdf.
* Slyusar, V. I. (1997-05-20). "Analytical model of the digital antenna array on a basis of face-splitting matrix products.". Proc. ICATT-97, Kyiv: 108–109. http://slyusar.kiev.ua/ICATT97.pdf.
* Slyusar, V. I. (1997-09-15). "New operations of matrices product for applications of radars". Proc. Direct and Inverse Problems of Electromagnetic and Acoustic Wave Theory (DIPED-97), Lviv.: 73–74. http://slyusar.kiev.ua/DIPED_1997.pdf.
* Slyusar, V. I. (March 13, 1998). "A Family of Face Products of Matrices and its Properties". Cybernetics and Systems Analysis C/C of Kibernetika I Sistemnyi Analiz.- 1999. 35 (3): 379–384. doi:10.1007/BF02733426. http://slyusar.kiev.ua/FACE.pdf.

0.00

(0 votes)

Original source: https://en.wikipedia.org/wiki/Tensor sketch. Read more

|

Retrieved from "https://handwiki.org/wiki/index.php?title=Tensor_sketch&oldid=326802"
*[v]: View this template
*[t]: Discuss this template
*[e]: Edit this template