PackedSequence: How to restore identity after pressing the sequence

When recycling the network processes the long sequence, you can skip the position by packing it.

• Step by stepCollate in 2 self-measured2 First-hand sources
Start Body
Learning objectives and first steps2 objectives 2 first fixes

Try to do it after reading

  • Manual valid batch size time-step
  • Distinguishing the final active status from the last position to the end of completion

Suggested first

  • Python Basic Syntax:
  • Thick shape with Index

You need to know what's missing without padding

When recycling the network processes the long sequence, you can skip the position by packing it. Rather than simply connecting all samples into a long sequence, it organizes samples that were still valid at the time and records the information needed to restore the structure. The values are even lower after pressure and the sample identity and time boundary must remain.

Take the sequence A = [1,2,3], B = [4] in descending order of length. Step 0 has A and B, value [1,4]; Step 1 has only 2 of A; Step 2 has only 3 A. The packing order may be understood as [1,4,2,3], and batch_sizes[2,1,1]. It contains four valid values, not six values for padding.

If the original order is not entered, the frame may be sorted by option and the index may be restored; The caller still needs to confirm the order in which the output, hidden state and label are returned. It cannot be inferred solely from the first after packing that it was the first user in the original instalment. The external summary of the model and the log will also need to use a consistent map of identity.

The final active state shall be read in each length instead of directly completing the final position of the axis. A two-way circulation network is more important to distinguish between the integration output of a positive, reverse, end state and a time position; These objects may have similar shapes but represent different historical coverages and cannot be exchanged in the same dimensions.

A zero length, longer than the actual time dimension, longer dtype and equipment are subject to specific API. Common pack Interfaces are specifically required for long-length devices to check the listed versions of documents before they are used, rather than moving all fields together if they have been misreported GPU 。 The recovery should also be completed with a clear overall length and batch priority layout.

The effective length of the package input must be consistent with the true sequence, the actual event will be intercepted too briefly and the completion will be considered effective by the too long. A long error cannot normally be detected only by the final output of shape. The trueness of the long sequence savings can be measured by comparing the output meaning of the same small batch as the baseline for packing and the correct mask; Tightness does not in itself amount to a more accurate model.

Why is batch_sizes not [3,1]?

It records the number of active samples in a time-step manner and does not directly store the length of each sample. This is followed by 2, 1, 1.

Can you lose the length information when you pack it with a total value of 4?

No, the same four values can be derived from different sequence combinations; Structure information determines which values belong to the same sample and time location.

The restoration order should be in a clear inverse, rather than in a sequence of lengths. The same length produces parallel entries, and the sample cannot be re-identified by length alone. Retain a stable number for each sample and allow the number, initial status and label to be replaced to check model output by strip.

Sources and reconciliations

Definitions, methods and interfaces are available.

  1. PyTorch — Datasets and DataLoaders
  2. torch.nn.utils.rnn.pack_padded_sequence

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.

← Back to the knowledge directory
Ask Max Ask about this site
Ask Max ↗

Opening the assistant…

Paper figure

Photo comments

LEAVE A NOTE

About this photograph

Connecting to the discussion board…

    Comments become public after moderation. You can delete your own comments from this browser.
    No email is required. Clearing cookies prevents this browser from claiming earlier comments.

    MAX WANG / INDEX

    Find something

    Enter a keyword, or explore the directory below.