Binary Operations

dot

The inverse operation of dot is dot.

class auto_diff.OpDot(x: auto_diff.op.operation.Operation, y: auto_diff.op.operation.Operation, **kwargs)[source]

Bases: auto_diff.op.operation.Operation

Dot product of two tensors.

If either x or y is a scalar, then it is equivalent to OpMultiply.

If both x and y are 1-D arrays, it is the inner product of vectors, the result is a scalar:

z=kxkyk

Partial derivatives of a single element:

Lxi=Lzzxi=Lzyi
Lyi=Lzzyi=Lzxi

Vector derivatives:

Lx=Lzy
Ly=Lzx

Note that since z is a scalar, the calculation of vector derivatives in this case is the dot operation.

If both x and y are 2-D arrays, it is the matrix multiplication, the result is a 2-D array:

zij=kxikykj

Partial derivative of a single element:

Lxij=a,bLzabzabxij=a,bLzab(kxakykb)xij=bLzib(xijyjb)xij=kLzikyjk=k(LZ)ik(YT)kj
Lyij=k(XT)ik(LZ)kj

The results of partial derivatives are the same as the definition of the dot operation, therefore the matrix derivatives are:

LX=LZYT
LY=XTLZ

If x is an N-D tensor and y is an M-D tensor (M >= 2), it is a sum product over the last axis of x and second-to-last axis of y.

If x is an N-D tensor and y is a 1-D array, it is a sum product over the last axis of x and y. It is a special case of the previous condition if y is considered as a K x 1 matrix and result is squeezed.

__init__(x: auto_diff.op.operation.Operation, y: auto_diff.op.operation.Operation, **kwargs)[source]

Initialize self. See help(type(self)) for accurate signature.