Conversion and continuity: exchange semantic and arrange memory
Sequence data are commonly used [B], T, D], and some calculations are expected [B], D, T].
Learning objectives and first steps2 objectives 2 first fixes
Try to do it after reading
- Write batch time features for three axes
- Separate Axis Changes Correct and Layout Performance
Suggested first
- Python Basic Syntax:
- Thick shape with Index
On the shape, the wrong layer may still be reached
Sequence data are commonly used [B], T, D], and some calculations are expected [B], D, T]. This is not a question of the order of the three numbers, but rather of the objects that each axis represents. (b) The conversion shall be preceded by the matching of each number to its batch, time and identity; Continuity addresses how these numbers are arranged to fit the follow-up visit, and does not mix the two things.
Take B = 1, T = 2, D = 3, and enter into two time locations [1,2,3] and [4,5,6]. After conversion to [B], D, T], the time series for the three characteristics shall be [1,4], [2,5], [3,6]. If only the six values were recomposed by 3 x 2, the values would have been obtained [1,2], [3,4] and [5,6], and shape would have been the same, but the semantics would have been wrong.
When the right logic is obtained by using the axle exchange, the volume may be non-continuous. Many framework algorithms handle non-continuous input, and some paths are reproduced internally or require specific layouts. Whether or not to be visible contiguous should be determined by interface and physical performance measurements, not all non-continuous situations need to be repaired immediately. Blind copying will allow the big batch to occupy extra memory.
In the image, there are similar problems with NCHW and NHWC. Some optimized memory formats change access, but not necessarily the axle meanings seen by users; The channels_last layout option cannot be simply used as a synonym for manual permute. The weights, input and arithmetical support need to be checked together, especially when the model is exported or moved across frames.
Errors can be assigned to unique numbers of each location, such as 100 x batch + 10 x time + characteristics, and the location of each value after conversion can be checked. It's easier to locate which axle exchange than to observe random loads. Recalculation time, calculation time and peak memory are then measured separately to avoid miscalculating the cost of data replication as model costing.
The exchange axis first changes the logical indexing relationship, and whether to duplicate storage is another issue. The follow-up contiguous may be copied, but it will not allow for the exchange of wrong semantic axes. The correctness test and speed measurement should be separated from the axle semantic check that a path could not skip more quickly, nor could the case be moved to an unmeasured acceleration rate.
Where different sources use different axle protocols, the interface boundary should be named and asserted, rather than relying on downstream speculation.
[1,4] Why should it be placed in the first characteristic sequence?
They all come from column 0 of the characteristic axis, corresponding to two time slots; Axis exchanges retain this identity.
Does non-continuing represent a numerical error?
No, it merely states that the layout is not consistent with a continuing agreement. The numeric syntax and the arithmetic are to be examined separately for efficient processing.
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.