A calculating FIG.
1, FIG calculated for describing operation of the directed acyclic graph.
- There are two main elements: nodes (Node), the edge (Edge)
- Nodes represent the data , such as a vector, matrix, tensor
- Edges represent operation , such as addition, subtraction, etc. convolution
Examples: FIG calculation represented by y = (x + w) * (w + 1)
拆分:a = x + w b = w + 1 ---> y = a * b
2, FIG calculated gradient derivative
=b * 1 + a * 1
=b + a
=(w+1) + (x+w)
=2*w + x + 1
=2 * 1 + 2 + 1
=5
all paths to y w
3, the leaf nodes: User-created node is called a leaf node, such as X and W
- is_leaf: tensor indicating whether the leaf node
- retain_grad (): save the corresponding gradient tensor
- grad_fn: recording method (function) --- creating this back-propagation tensor commonly used
Results: y.grad_fn = <MulBackward0>
a.grad_fn = <AddBackward0>
b.grad_fn = <AddBackward0>
II Dynamic Graph Dynamic FIG.
- FIG Dynamic: computing and simultaneously build --- PyTorch flexible, easy to adjust
- Static map: build first, rear operations --- tensorflow efficient, inflexible