Processes for performing singular value decomposition on a matrix or tensor, and working with the results.
This class wraps the U, Sigma (S) and V matrices that result from computing an SVD. An SVD decomposes the matrix A such that A = U*S*(V^T). Both U and V are orthonormal matrices, and S is a diagonal matrix.
This class also provides utility methods to make common SVD-related math easy.
The constructor makes an SVD2DResults object from the matrices created by an SVD. Note that svals is a 1-D vector of sigma values from the SVD.
Get the weighted u vector with key idx.
If idx is not present and default_zeros is true, returns a vector of zeros.
Get the weighted v vector with key idx.
If idx is not present and default_zeros is true, returns a vector of zeros.
This class wraps the results of a 2-D SVD (represented by an SVD2DResults object) and behaves like the Tensor created by multiplying together the U, S and V matrices of the SVD result.
Reconstructed2DTensors require much less storage space than the actual reconstructed tensor. However, access times for a Reconstructed2DTensor are slower, since accessing an entry requires computing a dot product.
The constructor creates a Reconstructed2DTensor from a SVD2DResults object.
Stores the results of an arbitrary higher-order SVD. If you are simply taking the SVD of a matrix, you are probably looking for the SVD2DResults class.
self.r is a list of SVD2DResults, one for each unfolding of the tensor.
A ReconstructedTensor is a wrapper around a SVDResults object. The ReconstructedTensor behaves like the tensor constructed by multiplying together the U, Sigma and V matrices (reconstructing the original matrix from its SVD).
ReconstructedTensors require much less storage space than the actual reconstructed tensor would require. However, access times for a ReconstructedTensor are slower, since accessing an entry requires computing a dot product. To mitigate this problem, ReconstructedTensors cache the values of recently-accessed entries.
The constructor creates a ReconstructedTensor from a SVDResults object.
Compute SVD of 2-D tensor tensor using an incremental SVD algorithm. This algorithm ignores unknown entries in the sparse tensor instead of treating them as zeros (like Lanczos’ algorithm does). This means that the incremental SVD of a sparse matrix will not necessarily equal the Lanczos’ SVD of the same matrix.
The incremental SVD algorithm performs gradient descent to find the U, V and S matrices that minimize the Root Mean Squared error of the reconstructed matrix.
The optional parameter k is the number of sigma values to retain (default 50). The lrate parameter controls the “learning rate,” a factor that changes the rate of gradient descent (default .1). A larger value means the gradient descent will take larger steps toward its goal. Setting lrate to a “large” value may cause the algorithm to diverge, and will cause a mysterious overflow error. The niter parameter controls the number of steps performed by the gradient descent process (default 100).