sparse-matrix

Does Keras 1.0 support scipy sparse matrices?

戏子无情 提交于 2019-12-10 17:13:45
问题 I can't find a definitive answer on whether keras supports scipy sparse matrices as training / testing vectors. I've read this link, which seems to imply that it doesn't https://www.kaggle.com/c/walmart-recruiting-trip-type-classification/forums/t/18154/training-neural-network-with-scipy-sparse-matrix. This PR seems to imply that it does, though https://github.com/fchollet/keras/pull/1886. The docs don't state explicitly -- could someone shed some light? Thanks 来源: https://stackoverflow.com

Extracting blocks/ROIs from Eigen::SparseMatrix without copying

时光总嘲笑我的痴心妄想 提交于 2019-12-10 16:18:05
问题 I wonder is there any good way to extract blocks/ROIs from Eigen::SparseMatrix? More precisely, what I want to extract is inner vectors . What I want to do is like: typedef Eigen::SparseMatrix<double,Eigen::RowMajor> SpMat; // Prepare some sparse matrix SpMat spmat; // Extract lines from it const SpMat& row_i = spmat.innerVector(i); const SpMat& row_j = spmat.innerVector(j); // Some calculation with row_i and row_j... As I tested, the data of row_i and row_j is copied (!!) from spmat .

Slicing a scipy sparse matrix using a boolean mask

房东的猫 提交于 2019-12-10 16:12:34
问题 I have encountered a difference in how slicing a scipy sparse matrix works in 0.10.0 and 0.10.1. Consider the following piece of code: from numpy import array, ravel from scipy.sparse import csr_matrix mat = csr_matrix(array([[1, 0, 0], [0,1,0], [1,0,0]])) desired_cols = ravel(mat.sum(0)) > 0 print mat[:, desired_cols].A In scipy 0.10.0, I get what I expect to get: [[1 0] [0 1] [1 0]] In 0.10.1 and 0.12.0, I get [[0 0 1] [1 1 0] [0 0 1]] I am not sure if this is a bug or I am doing something

scipy.sparse.linalg.spsolve surprising behaviour for large sparse matrices on Linux systems

天大地大妈咪最大 提交于 2019-12-10 15:55:32
问题 I am computing the solution of a linear system Ax=b with A a large (typically 200,000 lines and columns for the associated dense matrix) sparse matrix and b a sparse matrix of about 100 columns. When I run my code on Windows systems (Python 2.7 , scipy 0.14.0 ), the following command from scipy.sparse.linalg import spsolve ... Temp = spsolve(A.tocsc(),b.tocsc()) runs smoothly and requires about 7 GB of ram memory. Running the exact same code with the exact same matrices on Linux systems (same

Scipy sparse matrix alternative for getrow()

人走茶凉 提交于 2019-12-10 15:36:28
问题 I am working with large sparse binary matrices. I have condensed them using Scipy sparse matrix implementation. The calculation of Jaccard distance from scipy.spatial.distance does not support direct operation on sparse matrices, so either: convert the entire sparse matrix to dense and then operate on each row as vectors which is memory hungry or Loop through the sparse, grab each row using getrow() and operate. or Write our own implementation to work on sparse matrices. To put things to

Rearrange sparse arrays by swapping rows and columns

前提是你 提交于 2019-12-10 15:23:42
问题 I have large but sparse arrays and I want to rearrange them by swapping rows an columns. What is a good way to do this in scipy.sparse ? Some issues I don't think that permutation matrices are well suited for this task, as they like randomly change the sparsity structure. And a manipulation will always 'multiply' all columns or rows, even if there are only a few swaps necessary. What is the best sparse matrix representation in scipy.sparse for this task? Suggestions for implementation are

Extract a block from a sparse matrix as another sparse matric

老子叫甜甜 提交于 2019-12-10 14:59:24
问题 How to extract a block from a Eigen::SparseMatrix<double> . It seems there aren't the methods I used for the dense ones. ‘class Eigen::SparseMatrix<double>’ has no member named ‘topLeftCorner’ ‘class Eigen::SparseMatrix<double>’ has no member named ‘block’ There is a way to extract a block as a Eigen::SparseMatrix<double> ? 回答1: I made this function to extract blocks from a Eigen::SparseMatrix<double,ColMaior> typedef Triplet<double> Tri; SparseMatrix<double> sparseBlock(SparseMatrix<double

Is there a faster way to subset a sparse Matrix than '['?

一笑奈何 提交于 2019-12-10 14:15:22
问题 I'm the maintainer of the seqMeta package and looking for ideas on how to speed up the bottleneck of splitting a large matrix into smaller pieces a large number of times. Background The seqMeta package is used to analyze genetic data. So you have a group of subjects (n_subject) and a number of genetic markers (n_snps). This leads to a n_subject x n_snp matrix (Z). There is also a data frame that tells you which snps get grouped together for analysis (typically which snps comprise a given gene

How to deal with nonzero elements from rows of sparse matrix in Matlab?

房东的猫 提交于 2019-12-10 12:12:16
问题 I am dealing with quite a big sparse matrix, its size is about 150,000*150,000. I need to access into its rows, extract the non-zero elements and replace these values following the rule as the code below: tic H = []; for i = 1: size(A,2) [a,b,c] = find(A(i,:)); % extract the rows add = diff([0 c(2:end) 0]); % the replacing rule aa = i*ones(1,size(a,2)); % return back the old position of rows G0 = [aa' b' add']; % put it back the old position with replaced values H = [H; G0]; end H1 = H(:,1);

R: initialise empty dgCMatrix given by matrix multiplication of two Quanteda DFM sparse matrices?

隐身守侯 提交于 2019-12-10 11:57:03
问题 I have for loop like this, trying to implement the solution here, with dummy vars such that aaa <- DFM %*% t(DFM) #DFM is Quanteda dfm-sparse-matrix for(i in 1:nrow(aaa)) aaa[i,] <- aaa[i,][order(aaa[i,], decreasing = TRUE)] but now for(i in 1:nrow(mmm)) mmm[i,] <- aaa[i,][order(aaa[i,], decreasing = TRUE)] where mmm does not exist yet, the goal is to do the same thing as mmm <- t(apply(a, 1, sort, decreasing = TRUE)) . But now before the for loop I need to initialise the mmm otherwise Error: