Questions tagged [matrix]

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

In mathematics, a matrix (plural: matrices) is a rectangular array of numbers, symbols, or expressions, arranged in rows and columns.

77 questions
7
votes
1 answer

Comparing transition matrices for Markov chains

I have a population, each unit of which exists in one of several states that change over time. I am using first-order Markov chains to model these state transitions. My population can be segmented into various subpopulations of interest. I've…
R Hill
  • 1,095
  • 10
  • 19
5
votes
1 answer

What types of matrix multiplication are used in Machine Learning? When are they used?

I'm looking at equations for neural networks and backpropagation and I see this symbol in the equations, ⊙. I thought matrix multiplication of neural networks always involved matrices that matched dimensions on both sides, such as... [3, 3]@[3, 2].…
Ant
  • 177
  • 1
  • 5
5
votes
1 answer

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 embeddings of two words each, obtained from…
5
votes
2 answers

Normalize matrix in Python numpy

I've an array like this: array([[ 0, 1], [ 2, 3], [ 4, 5], [ 6, 7], [ 8, 9], [10, 11], [12, 13], [14, 15]]) I want to make normalize this array between -1 and 1. I'm currently using…
Tarlan Ahad
  • 271
  • 2
  • 5
  • 15
5
votes
0 answers

How is image convolution actually implemented in deep learning libraries using simple linear algebra?

As a clarifier, I want to implement cross-correlation, but the machine learning literature keeps referring to it as convolution so I will stick with it. I am trying to implement image convolution using linear algebra. After looking around on the…
3
votes
1 answer

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 be float type while np.linalg.pinv could be used with…
eMichel
  • 33
  • 4
3
votes
2 answers

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: # convert from data frames to numpy matrices X = np.matrix(X.values) y = np.matrix(y.values) theta = np.matrix(np.array([0,0])) When I came accross this line : …
2
votes
1 answer

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, each with several attributes (screen size, case…
Insu Q
  • 181
  • 2
  • 6
2
votes
1 answer

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 all dimension?
2
votes
1 answer

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 output. Now suppose that instead of scalars I want to operate on 1d vectors (e.g. word…
Pat Niemeyer
  • 133
  • 4
1
vote
0 answers

Efficient method of performing within matrix similarity

I want to compute a similarity comparison for each entry in a dataset to every other entry that is labeled as class 1 (excluding the current entry if it has a label of 1). So, consider a matrix of training data that has columns for ID and…
CopyOfA
  • 167
  • 5
1
vote
3 answers

converting array to a true/false matrices

I have a data set where each record is a json document with a label, and an array of signals. The signals will vary for each record: { "label":"bad", "id": "0009", "signals":["high_debt_ratio", "no_job"] }, { "label":"good", …
Cyph
  • 111
  • 2
1
vote
1 answer

PCA, covariance, eigenvector matrix and rotation

I am following the Coursera NLP specialization, and in particular the lab "Another explanation about PCA" in Course 1 Week 3. From the lab, I recovered the following code. It creates 2 random variables, rotates them to make them dependent and…
1
vote
1 answer

Matrix notation in Sutton and Barto

On pg. 206 of Barto and Sutton's Reinforcement Learning, there is a curious statement about the result of a scalar product: As I interpret it, A is the expectation of a scalar product of two d-dimensional vectors: which should be a scalar, right?…
corazza
  • 113
  • 5
1
vote
0 answers

How can I get a value of context vector in GPT?

I'm a newbie in NLP and I'm now stuck in GPT. The question I'm struggling with is related to a term 'context vector' It says in the following (sorry that the material provided is written in korean) that U represents a context vector. I searched for…
Jiyoon
  • 11
  • 1
1
2 3 4 5 6