# temporal_shift¶

paddle.nn.functional. temporal_shift ( x, seg_num, shift_ratio=0.25, name=None, data_format='NCHW' ) [source]

Temporal Shift Operator

Calculate the temporal shifting features for Input(X).

Input(X) should be in shape of [N*T, C, H, W] or [N*T, H, W, C], while N is the batch size, T is the temporal segment number specified by `seg_num`, C is the channel number, H and W is the height and width of features.

Temporal Shifting is calculated as follows when data format is NCHW:

Step 1: Reshape Input(X) to [N, T, C, H, W].

Step 2: Pad 0 to reshaping result in the 2nd(T) dimension with padding width as 1 on each side, padding result will be in shape of [N, T+2, C, H, W].

Step 3: Assume `shift_ratio` is \(1/4\), slice padding result as follows:

\$\$ slice1 = x[:, :T, :C/4, :, :] \$\$ \$\$ slice2 = x[:, 2:T+2, C/4:C/2, :, :] \$\$ \$\$ slice3 = x[:, 1:T+1, C/2:, :, :] \$\$

Step 4: Concatenate three slices along the 3rd(C) dimension and reshape result to [N*T, C, H, W].

For details of temporal shifting, please refer to paper: Temporal Shift Module .

Parameters
• x (Tensor) – \${x_comment}

• seg_num (int) – \${seg_num_comment}

• shift_ratio (float) – \${shift_ratio_comment}

• name (str, optional) – For detailed information, please refer to Name. Usually name is no need to set and None by default.

• data_format (str, optional) – Data format that specifies the layout of input. It can be “NCHW” or “NHWC”. Default: “NCHW”.

Returns

The temporal shifting result is a tensor with the same shape and same data type as the input.

Return type

out(Tensor)

Examples

```import paddle