padded_batch: Completion of position is not zero observed
padded_batch fills the short records to the public shape when long sequences are taken.
Learning objectives and first steps2 objectives 2 first fixes
Try to do it after reading
- Separate completion value from true validity
- Serial loss at valid position
Suggested first
- Python Basic Syntax:
- Counting and training closed
The two zeros can't be mixed
padded_batch fills the short records to the public shape when long sequences are taken. The completion value is often zero, but zero is not necessarily missing in itself. For example, a daily transaction of 0 may be a real observation, and the validity length cannot be inferred directly from the “value of 0”. The reliable practice is to retain the true length or to carry an independent valid location mask.
The sequences are [2,4,6] and [8], completed and completed in [[2,4,6], [8,0,0], shape [2,3]. Valid mask is [1,1,1], [10,0]. The global effective average is 20/4 = 5 and the direct average is 20/6 for six grids, approximately 3.333. The decrease in values was due to a change in denominators, rather than the model finding a lower intensity of behaviour.
If the task requires an average of each user and an average of users, the result is different: the average value of the two sequences is 4 and 8, respectively, and the average of the users is 6. Both 5 and 6 may be reasonable, corresponding to each event and the rights of each user, respectively. Define the unit of assessment and then decide how mask will enter the molecular denominator, which cannot be left empty.
mask needs to continue on the network
Some Keras layers support mask dissemination, while some custom changes require explicit treatment. The axial meaning of the original mask is updated when the sequence is changed from [batch, time, feature] to another layout. mask was created without attention, pool or loss, which would also result in contamination.
Embedding It's... mask_zero I'll have to keep index 0 for sure when we're done. padding 。 If the list allocates 0 to a true word, all the positions of the word may be considered invalid. The same numbering rule should be maintained between the construction of the glossary, the data export and the service input. Numerical series is more suitable for visible lengths, and there is no need to force all fields to share a sentry value.
Errors can construct a single reasoning for a record, which is combined with longer records for approval. For outputs that are not theoretically related to padding, the result should be close. If there is a significant difference, check the pool denominator, the attention mask and whether or not the standardization mixes the time axis into statistics.
This section concerns masking interfaces supported by TensorFlow 2 and Keras 3; consult the documentation for each layer. The values 5, 6 and 3.333 are calculated by hand from fixed teaching data.
Value recovery
rows=[[2,4,6],[8,0,0]]mask=[[1,1,1],[1,0,0]]total=sum(x*m for r,ms in zip(rows,mask) for x,m in zip(r,ms))count=sum(sum(ms) for ms in mask)assert total/count == 5After mask, set invalid loss to zero. Why is it possible that the direct mean is still wrong?
Because the denominator of mean may still contain the patches. The sum of the valid loss is required to be divided by the number of valid locations or returned to the specified user rights.
How can a sequence model be tested for being interfered with by a full length?
Maintains the true sequence unchanged, changes only the length of other sequences in the same batch or completes them, compares the output and examines mask dissemination on a layer-by-layer basis.
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.