Movement Operations¶
Operations like transpose, reshape and squeeze only move the elements to other locations. The number of elements would not change after these operations. The back propagation of a movement is another movement, and more specifically, its inverse operation.
transpose¶
The inverse operation of transpose is transpose.
-
class
auto_diff.
OpTranspose
(x: auto_diff.op.operation.Operation, axes: Optional[Sequence[int]] = None, **kwargs)[source]¶ Bases:
auto_diff.op.operation.Operation
Transpose the tensor.
Basic operation without axes:
Y=XTPartial derivative of a single element:
∂L∂xij=∑i,j∂L∂yij⋅∂yij∂xij=∂L∂yji⋅∂yji∂xij=∂L∂yji⋅∂xij∂xij=∂L∂yjiMatrix derivative:
∂L∂X=(∂L∂Y)TGenerally, axes should be a permutation of the dimensions, suppose there is a function f that maps from (0,1,…,k) to the new permutation, then this transpose operation would be:
yi1,i2,…,ik=xf(i1),f(i2),…,f(ik)The partial derivative of xi1,i2,…,ik is 1 only with yf(i1)−1,f(i2)−1,…,f(ik)−1. Therefore the derivative should be another transpose operation with inverse mapping function f−1.