Matrix Calculator: Multiply, Inverse, Eigenvalues, SVD, Softmax and Attention

Free matrix calculator that shows the working: multiply, add, transpose, determinant, inverse, rank, row reduction, eigenvalues, SVD and QR, plus the machine-learning operations: softmax with temperature, activation functions, a dense neural-network layer and one attention step. Private: nothing is uploaded.

One row per line (or separate rows with ;). Numbers can be separated by spaces or commas, and can be fractions like 1/3 or pi.

Try an example:

A matrix calculator that explains the machine-learning parts

Matrices are how a neural network stores what it has learned and how it computes: a layer is y = activation(W·x + b), a language model's attention is softmax(Q·Kᵀ/√d)·V, and training changes the numbers inside the matrices. This calculator does the usual linear algebra (add, multiply, transpose, determinant, inverse, rank, eigenvalues, SVD, solving equations) and shows the working, and it has the machine-learning operations built in: softmax with temperature, the common activation functions, one dense layer and one attention step.

Questions

Why do the shapes have to match?

To multiply A × B, A's columns must equal B's rows, because each result number is a row of A paired up, one by one, with a column of B. Click any number in a product to see exactly which pairs were multiplied and added. The result has A's rows and B's columns. This is why a layer with 784 inputs and 128 neurons has a 128 × 784 weight matrix.

What is the inverse for?

The inverse undoes a matrix (A⁻¹·A = I). It exists only when the determinant is not 0. Solving A·x = b is the same as x = A⁻¹·b, which is how linear regression's normal equation works. The page shows the row operations that get there.

What do eigenvalues and SVD mean in machine learning?

Eigenvectors are the directions a matrix only stretches; the eigenvalues say by how much. For a symmetric matrix such as a covariance matrix they give the principal components (PCA). SVD does the same job for any rectangular matrix and is behind compression, recommendations and low-rank fine-tuning.

What do softmax and temperature do?

Softmax turns any list of numbers (scores) into probabilities that add up to 1 by giving bigger scores much bigger shares. A low temperature makes the biggest score win almost every time; a high temperature spreads the probability out. Language models use exactly this to pick the next word.

Is the working exact?

Numbers are double-precision decimals, so results can be off in the 15th digit and tiny values show as 0. Fractions are found for display (for example 0.3333 shows as 1/3). Everything is computed in your browser; nothing is sent anywhere.

Comments
Advertisement