# Questions tagged [matrix]

A matrix is a collection of numbers arranged into a fixed number of rows and columns.

42 questions
Filter by
Sorted by
Tagged with
47k views

### Normalize matrix in Python numpy

I've an array like this: ...
2k views

### Calculating cosine similarity between 3D arrays using Python

I have two matrices with multiple columns and three rows each. I calculated the cosine similarity (sklearn) but it gives the result as a matrix. How can I obtain one single value? The matrices are the ...
158 views

### Is there a difference between np.matrix(np.array([0,0])) and np.matrix([0,0])?

I was reading this code, for implemnting linear regression from scratch: ...
87 views

### tensorflow pseudo inverse doesn't work for complex matrices!

The Tensorflow documentation here says that: tf.linalg.pinv is ''analogous to numpy.linalg.pinv. It differs only in default value of rcond''. However, tf.linalg.pinv requires the matrix to ...
19 views

### Recommender system that matches similar customers with similar highly rated products?

I have a dataset of 1,000 customers that bought 20 distinct phones and rated them 1-5. I have several demographic attributes for these customers (gender, age). My website offers 100 distinct devices, ...
140 views

### How can I create convolutions or linear layers that operate on vectors rather than scalars in pytorch?

Consider an nn.Linear(2,3) layer transform like the one below. It uses a 2x3 matrix of scalar weights to create a weighted sum for each scalar element in the ...
40 views

I have a $(418,2)$ matrix and I want to convert it to csv. so I write: np.savetxt('titanic1.csv', Sol, fmt='%.2f', delimiter=",",header="PassengerId,Survived") ...
554 views

### How to correctly pass Word2Vec vectors as input to an LSTM

I am trying to build a text classifier using lstm which, in its first layer, has weights get by a Word2Vecmodel. In order to ...
572 views

### Computation of kernel matrix using radial basis kernel in svm

I want to compute a kernel matrix using RBF on my own. The training data is multidimensional. My query is whether we will apply $$e^{-\gamma(x-y)^2}$$ for each dimension and then sum the values across ...
1k views

### Python memory error: compute inverse of large sized matrix

I have a big matrix of size 200000 x 200000. I need to compute its inverse. But it gives out of memory error on using numpy.linalg.inv. Is there any way to compute the inverse of a large sized matrix.
92 views

### Faster 3D Matrix Operation - Python

I am working with 3D matrix in Python, for example, given matrix like this with size of 2x3x4: ...
277 views

### How are weights calculated in a feed-forward neural network before they are summed up with bias?

I have read a lot of papers and watched different videos, it seems like they explain how they are summed up with bias before entering the activation function. What I am trying to understand is the ...
29 views

### Is this matrix correctly built?

I was reading an article called "Ensemble learning in recommender systems: combining multiple user interactions for ranking personalization" where they explain a method they use called "BPR ...
13 views

### What is the kernel matrix used for in the kernel trick?

I have $n$ linearly inseperable datapoints, $x_1 \dots , x_n$. I use the kernel trick to map and compute the dot product in higher dimensions (without actually mapping / transforming the data). ...
52 views

### Scipy Sparse vstack memory error

I have a bunch of scipy matrices (of the same #columns) loaded from disk. I want to combine them into one scipy sparse matrix. I am using scipy sparse vstack method. I am able to load the ...
12 views

### Question regarding: Vectorization Math of Backpropagation in a Neural Network

Formula: These are the formula I use for backpropagation from Brilliant: Question: If we consider a Neural Network with the structure (3,2): And we would start calculating the derivative (for 1 ...
48 views

### List of Correlations to Correlation Matrix [closed]

I am using python to do some data analysis and I need to represent the following table as a correlation matrix. The correlation value is a value between -1 and 1. ...
139 views

### Dataset containing spatial and temporal features (built on a CNN model)

A dataset contains spatial and temporal features. It contains the time series data (2 min intervals) of the sections of a map. It is 320*480 (320 map sections and 480-time intervals). Each row ...
25 views

### How to create a matrix from two given vectors in R in RStudio?

Suppose, $c(1, 2, 3, 4)$ and $c(2, 4, 5, 6)$ are two vectors. Then in R or RStudio, How to create a $4\times 2$ matrix from these two vectors? Also, how to add another vector $c(8, 9, 10, 11)$ ...
192 views

### Normalize / Standardize in a Random Forest?

If I have a matrix of co-occurring words in conversations of different lengths, is it appropriate to standardize / normalize the data prior to training? My matrix is set up as follows: one row per ...
216 views

### how exp(-z) is working in a sigmoid function in neural networks while z is a matrix?

function g = sigmoid(z) %SIGMOID Compute sigmoid function J = SIGMOID(z) computes the sigmoid of z.% g = 1.0 ./ (1.0 + exp(-z)); end i'm going through andrew ng coursera course i have a doubt ...
583 views

### How can I perform backpropagation directly in matrix form?

I had made a neural network library a few months ago, and I wasn't too familiar with matrices. So, instead of performing matrix dot products (between weights and inputs, then adding a bias matrix), I ...
13 views

### Can all known ML algorithms be written as a sequence of matrix operations?

I keep hearing that machine learning is just linear algebra. Does that mean all known (and all possible?) ML algos, from random forest, to support-vector machines, to recursive neural networks, can ...
12 views

### How to find same set of answers repeated for multiple questions

I am using azure Q&A for creating a knowledge base. My knowledgebase contains questions and answers. There are chances that many questions that have same meaning may give different answers. How ...
10 views

### How to use “transposing” for more efficient list comprehensions?

How can I use transposing to execute operations faster, than i currently do in list comprehensions, like: ...
21 views

### Trying to understand the result provided by np.linalg.norm function in numpy (normalisation)

I'm new to data science with a moderate math background. I'm playing around with numpy and can across the following: So after reading np.linalg.norm, to my ...
13 views

### Best machine learning approach for matrix training samples

I am quite a beginner in the field of machine learning, and I am not sure how to solve my problem. I need to evaluate the dynamics of a system composed of n elements, with each element represented by ...
36 views

### How do I use matrix math in irregular neural networks such as those generated from neuroevolution (NEAT)?

I understand how to structure the matrix when every node in a layer is fully connected to every node in adjacent layers and I understand that in "irregular" neural networks I can just process each ...
29 views

### How to compute Hessian matrix for log-likelihood function for Logistic Regression

I am currently studying the Elements of Statistical Learning book. The following equation is in page 120. It calculates the Hessian matrix for the log-likelihood function as follows \begin{equation} ...
18 views

### Correlation between numeric variables of different meaning

I have a data set containing information about buildings, such as the area code, the neighborhood code, the number of floors, the year in which the house was built and the year in which restorations ...
27 views

### Matrix multiplication doesn't work - no output

I am having problem in the Matrix multiplication of my Python neural network. Being still a High schooler, I know next to nothing about MM except a couple of tutorials. My Neural network was working ...
14 views

### Binary Matrix Factorization: Regularizer to encourage 1-0 matrices

I have the following problem: Given a (user, access rights) binary matrix, I need to find the best (user, role) x (role, access right) binary matrices to reconstruct the original matrix. The current ...
20 views

### Linear Regression Error in feature matrix step

I'm trying to code the design function used in linear regression using numpy and I get this error: Traceback (most recent call last): File "C:\Users\visha\AppData\Local\Continuum\anaconda3\lib\...
24 views

### One hot encoding of continuous floats using keras backend

I am trying to convert a vector of floats into a matrix similar to one hot encoding, but I want this to happen in non-discrete space to retain gradients. Therefore I am only able to use keras backend ...
610 views

### How do I generate a laplacian matrix for a graph dataset?

If I have a dataset in a csv that looks like the one shown below. How do I convert this into a laplacian matrix using Python?
93 views

### Transformation of matrix with missing values for hierarchical clustering

Comparing different variables, I got a matrix with lots of missing values. How do I have to transform the matrix below for hierarchical clustering? What I have already tried: ...
104 views

### Issue in computing matrix inverse

I need to compute inverse of a matrix that has very small values of the range of 10^-9. When I use numpy.linalg.inv it gives all entries of the inverse matrix as 0. I checked in the original matrix ...
42 views

### How does on test regression for a subspace or matrix factorization?

I've recently been reading a lot of papers and watching a lot of videos on both subspace learning, and matrix factorization. One thing is particularly eluding me though - how does any of this get ...
51 views

### Having difficult interpreting the eigenvectors for a simple 3x2 matrix

I calculated the eigenvectors and eigenvalues from a covariance matrix given a data matrix of 3 columns and 2 rows. I am trying to interpret results but I can't understand on how to interpret them. ...
40 views

### How do I find output size of a network?

The input to a convolutional layer of a neural network is an image of size $128\times 128\times 3.$ $40$ convolutional filters of size $5\times 5$ are applied to it. Would you get an output? If no ...
I am new to Python. I have a problem and I hope you can help me with this problem. I have 2 numpy array matrices: $X$ and $Y$. Each matrix has 652 rows and 652 columns. $X^T = X$, $Y^T = Y$. I must ...