padding_idx: Line zero and active length are two types of agreement
The padding index of Embedding can set special treatment for filling the position.
Learning objectives and first steps2 objectives 2 first fixes
Try to do it after reading
- Understanding the gradient limit for filling rows
- Check the additional effects of poolization and weight erosion
Suggested first
- Inner vectors & Parameters
- Classified loss and gradient
A special line does not automatically ignore the whole network
The padding index of Embedding can set special treatment for filling the position. In the PyTorch interface, the corresponding line does not participate in the regular check sheet gradient update; Default initialization is often zero, but the user can modify the content of the line. It cannot be understood that all calculations of the model will automatically ignore it.
Set sequence numbers [1,2,0,0], 0 for padding, vector 1 = [2,0], 2 = [0,4], 0 = [0,0]. Directly averaged four positions was captured [0.5,1] and an average of two active positions was obtained [1]. Even if the correct vector is zero, the error denominator will change the length of the expression.
It is therefore necessary to retain mask or its true length and to use it for pool, attention and loss. Keras for mask_zero has its own mask dissemination semantic and cannot be mechanically equivalent to PyTorch for padding_idx. Both names involve completion, but interface behaviour differs from the level of subsequent support.
Special banks still need to check their life cycle
The words “without receiving a gradient from the checklist backward” and “no update can change the line” are not the same sentence. The weight decay of the optimist, manual weighting, load loading or other paths using the same matrix may affect it. If the system relies on the line to be strictly zero, it should be validated under the actual optimizer and shared weight scheme, rather than just looking at construction parameters.
If the output layer shares a matrix with the input Embedding, the padding line may also obtain a gradient from the output classification loss, depending on whether the category is excluded from the realization. At this point, the special treatment at the end of the check is not sufficient to bind all uses of the entire parameter. The shared path and category mask should be checked.
The term " 0 " does not represent a real category at the same time. Data export, training reading and online encoding must be using the same numbering protocol. One field maps the unknown word 0, the other field values the zero as padding, and also mistook the unknown as non-existent, which usually requires separate numbers.
This section is directed at the current open interface between PyTorch2 and Keras3 and is described in the completion mechanism for each framework. The vector mean value is a synthetic hand calculation. The check method is to maintain the true sequence unchanged, with only padding added and no variable expectations observed.
padding vector full zero, direct mean why could it still be wrong?
The denominators contain filled positions, indicating that they will shrink as the public length decreases and must be counted as valid locations.
Does padding_idx guarantee that the Bank will never be modified by any mechanism?
It cannot be summarized as such, and it binds the reverse path of the checklist; Other shared uses, decays or manual assigned values still need to be checked.
Sources and reconciliations
Definitions, methods and interfaces are available.
Figures and calculations are reorganized according to this chapter. Mathematical measurements, framework operations and real business effects are described separately in the body of the text.