Einstein Summation Notation We often want to do complicated matrix or vector operations that require careful manipulation to reduce to a correct output. The most explicit way of doing so would be to loop through each dimension of your ndarray and accumulate the result of each element-wise operation. This however can be very inefficient for a large matrix. The good news is, multiplying high dimensional matrices along specific dimensions need not be painful: enter Einstein notation. Equation Strings We often see things like np.einsum("i,i->", A, B) in code that relies heavily on tensor manipulation, e.g. machine learning code. It is a convenient way to express product sums of multi-dimensional tensors or arrays without explicitly writing out the underlying transposes or summations. Various libraries like NumPy , Tensorflow , and one of my new favorites einops , enable ways to evaluate summations of tensor products along specified dimensions by just specifying equation st
- Get link
- Other Apps