About Tensor Calculator
This tensor calculator is free, needs no sign-up and runs in your browser, so nothing you enter is uploaded. Type a tensor as nested brackets, such as [[1, 2], [3, 4]], and it works out the shape and rank for you, then lets you reshape it, transpose it, take its tensor product or Kronecker product with a second tensor, or evaluate an einsum expression.
It is built for the questions that come up when you work with arrays in NumPy, PyTorch or TensorFlow: what shape do I get, does this reshape fit, what does this einsum string actually compute? The answers show the rank, the shape, the number of elements and the values as nested brackets, so you can compare them with your code output.
The arithmetic is plain TypeScript running on the page, with no tensor library behind it. That keeps it small and private, and it means the rules are the standard ones: row-major order, NumPy-style Kronecker padding and Einstein summation over repeated letters. It handles numbers only, up to any rank the shapes allow, and it shows results as text. There is no 3D view and no complex numbers.
How to use Tensor Calculator
- Pick a mode: Shape and reshape, Tensor product, Kronecker product, or Einsum.
- Enter tensor A as nested brackets like [[1, 2, 3], [4, 5, 6]], or as a flat list of numbers with a shape such as 2, 3 in the shape box. One shape entry may be -1.
- For the product and einsum modes, enter tensor B the same way.
- In Shape mode, type a target shape to reshape to (for example 3, -1) and optionally an axes order for transpose (for example 1, 0).
- In Einsum mode, write the expression, such as ij,jk->ik, or pick an example chip: matrix product, trace, diagonal, transpose or a three-matrix chain. One box appears for each operand, labelled with its axes.
- Read the rank, shape and element count above each result, and the values below as nested brackets.
Features
- Shape inference from nested brackets, or a flat list plus a shape.
- Reshape with one -1 dimension worked out automatically.
- Transpose with reversed axes by default, or a custom axes order for any rank.
- Tensor (outer) product whose shape is the shape of A followed by the shape of B.
- Kronecker product with NumPy-style padding, so a vector and a matrix can be combined.
- Einsum with one, two or three operands: the trace (ii->), the diagonal (ii->i), the transpose (ij->ji), the matrix product, a three-matrix chain (ij,jk,kl->il), batch products and more, with an implicit output when you leave off the arrow.
- Each tensor box is labelled with the axes the expression gives it, and the expression is shown as a KaTeX formula.
- Shapes and small results are typeset with KaTeX, for example the shape as R with a superscript of 2 by 3 and a matrix as a bracketed array.
- A size guard: an einsum over 10 million multiply-adds is refused with the exact count, and one over 100,000 runs in a Web Worker so the page stays responsive.
- Readable errors for ragged lists, non-numbers, mismatched sizes and bad axes.
- Rank, shape and element count shown for every result, and values printed as nested brackets rounded to nine decimals.
The rules the calculator follows
A tensor is a block of numbers stored row-major with a shape. The number of elements is the product of the shape, and a reshape must keep that product. The tensor product multiplies every element of A with every element of B, so the result has shape A.shape + B.shape. The Kronecker product multiplies along matching axes, so axis sizes multiply instead.
Einsum names each axis with a letter. A letter that appears in the inputs but not in the output is summed over, and a letter in the output stays as an axis.
elements = product of shape
outer shape(A ⊗ B) = shape(A) + shape(B)
kronecker shape = shape(A)[i] × shape(B)[i] for each axis i
einsum ij,jk->ik C[i,k] = Σ_j A[i,j] × B[j,k]Worked examples
1, 2, 3, 4, 5, 6 with shape 2, 3, reshaped to 3, -1 gives A: rank 2, shape [2, 3], 6 elements. Reshaped: [[1, 2], [3, 4], [5, 6]] with shape [3, 2]. Transposed: [[1, 4], [2, 5], [3, 6]].
[[1, 2, 3], [4, 5, 6]] and [[1, 2], [3, 4], [5, 6]] with ij,jk->ik gives [[22, 28], [49, 64]], shape [2, 2].
This is the matrix product. For example 22 = 1×1 + 2×3 + 3×5.
[[1, 2], [3, 4]] and [[0, 1], [1, 0]] in Kronecker mode gives [[0, 1, 0, 2], [1, 0, 2, 0], [0, 3, 0, 4], [3, 0, 4, 0]], shape [4, 4].
Tensor product, Kronecker product and einsum compared
| Operation | Result shape for A [2, 2] and B [2, 2] | What it does |
|---|---|---|
| Tensor (outer) product | [2, 2, 2, 2], 16 elements | Multiplies every element of A by every element of B and keeps all axes |
| Kronecker product | [4, 4], 16 elements | Same 16 products, laid out as blocks so each axis multiplies |
| Einsum ij,jk->ik | [2, 2], 4 elements | Multiplies and sums over j, which is the matrix product |
Good to know
Entering tensors
Brackets must be rectangular: every row must be the same length. [[1, 2], [3]] is rejected. Brackets are read as JSON, so write 0.5 rather than .5 and leave no trailing commas. A flat list can be separated with commas, spaces, semicolons or line breaks, and with no shape it becomes a vector.
In the shape box use commas, spaces or an x, as in 2, 3 or 2x3x4. Only one entry may be -1.
Limits of the einsum mode
An expression takes one to three operands, and the page shows one tensor box for each. Repeating a letter inside one operand, as in ii, walks the diagonal. A calculation that needs more than 10 million multiply-adds (the product of every axis size times the number of operands) is refused, and one over 100,000 runs in a background Web Worker. Tensor and Kronecker products are limited to 10 million result values. Only letters are allowed as axis names, with no ellipsis. When you leave off the arrow, the output keeps the letters that appear once, in alphabetical order, as NumPy does.
Privacy: how it works
- All arithmetic is done by TypeScript code in your browser tab. There is no network request when you calculate, no library is downloaded to do it, and nothing is stored.
Tips
- Use -1 in a reshape to let the calculator fill in one dimension. A 24-element tensor reshaped to 4, -1 becomes shape [4, 6].
- If a reshape fails, multiply your target dimensions and compare with the element count shown for tensor A.
- To check an einsum string, try tiny tensors with distinct values, then compare the rank and shape before the values.
- A custom transpose order lists the old axes in their new positions. For shape [2, 3, 4], the order 1, 0, 2 gives shape [3, 2, 4].
Frequently asked questions
Is it really free?
Yes. There is no price, no trial and no credit card. Ulkaa Tool does the work with your own device, so there is no server bill to pass on to you.
Do I need an account?
No. There is no sign-up and no login. Open the page and use it. An Ulkaa account is not needed for anything on this tool.
Does it run in my browser?
Yes. Your values are processed by code running in your browser tab, on your own device.
Is my data uploaded?
No. Your values are never sent to Ulkaa or to anyone else. You can check this yourself by watching the Network tab in your browser developer tools while you use the tool.
What is a tensor?
A tensor is an array of numbers with any number of axes. A single number is rank 0, a list is rank 1, a matrix is rank 2, and higher ranks follow. Its shape lists the size of each axis.
What is the difference between a tensor and a matrix?
A matrix is a rank 2 tensor. A tensor can have any rank, so it can be a scalar, a vector, a matrix or a stack of matrices.
How do I find the shape of a tensor?
Enter it as nested brackets and read the Shape card. [[1, 2, 3], [4, 5, 6]] has shape [2, 3] and rank 2. With a flat list, the shape is the one you type, as long as its product equals the number of values.
How do I compute a tensor product?
Choose Tensor product, enter A and B, and read the result. Every element of A is multiplied by every element of B, and the result shape is the shape of A followed by the shape of B.
How many tensors can an einsum have?
One to three. One operand covers the trace (ii->), the diagonal (ii->i) and the transpose (ij->ji). Three operands cover chains such as ij,jk,kl->il.
Is there a size limit?
Yes. An einsum that needs more than 10 million multiply-adds is refused with a message that shows the count, and tensor or Kronecker products over 10 million result values are refused too. Anything over 100,000 multiply-adds runs in a Web Worker.
What does einsum do?
Einsum is Einstein summation. Each axis gets a letter, letters that repeat across inputs are multiplied together, and letters missing from the output are summed. ij,jk->ik is the matrix product.
Does it use TensorFlow or NumPy?
No. The calculations are written in plain TypeScript with no tensor library. The conventions match NumPy: row-major order and numpy.kron-style Kronecker padding.
Can it show a 3D view of a tensor?
No. Results are shown as ranks, shapes and nested brackets only.
Popular Tensor Calculator pages
- Tensor Product CalculatorThe tensor product of two tensors, with the result shape worked out.
- Tensor Shape CalculatorShape, rank and element count of a tensor, plus reshape and transpose.
- Einsum CalculatorEvaluate einsum expressions on one to three tensors and check your own.
- Kronecker Product CalculatorThe Kronecker product of two matrices, with block layout.
- Tensor Contraction CalculatorContract two tensors by summing over shared indices.