shuffle_batch¶
- paddle.fluid.contrib.layers.nn. shuffle_batch ( x, seed=None ) [source]
-
This layer shuffle input tensor
x
. Normally,x
is 2-D LoDTensor.x
is a LoDTensor to be shuffled with shape \([N_1, N_2, ..., N_k, D]\) . Note that the last dim of input will not be shuffled. \(N_1 * N_2 * ... * N_k\) numbers of elements with length \(D\) will be shuffled randomly.For Example:
Input: x.data = [[1, 2], [3, 4], [5, 6], [7, 8]] x.dims = [4, 2] Attrs: seed = 2019 Output: Out.data =[[7, 8], [1, 2], [3, 4], [5, 6]] Out.dims = [4, 2]
- Parameters
-
x (Variable) – The input variable. The input variable is a N-D LoDTensor with type int, float32 or float64.
seed (None|int|Variable) – The start up seed. If set, seed will be set as the start up seed of shuffle engine. If not set(Default), start up seed of shuffle engine will be generated randomly.
- Returns
-
The shuffled LoDTensor with the same shape and lod as input.
- Return type
-
Variables
Examples
import paddle.fluid as fluid x = fluid.layers.data(name="x", shape=[-1, 4]) out = fluid.contrib.layers.shuffle_batch(x)